Cannot create an NSPersistentStoreCoordinator with a nil model

前端 未结 27 1084
囚心锁ツ
囚心锁ツ 2021-01-30 03:33

Been having my first crack at Core Data and I\'m getting the following error when running my code on my device, but it works fine on the simulator..

*

27条回答
  •  星月不相逢
    2021-01-30 04:07

    I had the same problem, it worked fine on iOS6 but not on iOS5. This is how I solved it:

    1. Create a new Model version in xcode. (select the .xcdatamodeld, open the Editor menu and click "Add Model Version...")
    2. Compile and make sure that the new version works.
    3. Set the old one as current version. ("Current" in File Inspector for the .xcdatamodeld under Versioned Core Data Model)
    4. Remove reference to the .xcdatamodeld file in xcode
    5. Right click the .xcdatamodeld file in Finder and choose "Show Package Contents"
    6. Delete the new .xcdatamodel that you dont want
    7. Re-add the .xcdatamodeld in xcode
    8. Compile and smile

    (This is where I found how to delete a Model version: How to delete an old/unused Data Model Version in Xcode)

提交回复
热议问题