Cannot create an NSPersistentStoreCoordinator with a nil model

前端 未结 27 1054
囚心锁ツ
囚心锁ツ 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:17

    I know this doesn't solve your problem but I ran into this problem yesterday that plagued me for hours, the solution @Dominic Williams posted gave me a ArrayIndexOutOfBoundsException (whatever the Objective-C equivalent is).

    I'm not very good with Objective-C/Xcode yet but I'm working on an iOS app that our company had (mostly) developed externally. Unfortunately, they would often forget how to use a keyboard and would use capital letters interchangeably or spell properties incorrectly but were too lazy to go back and change it. They had used a capital letter in the xcode project name where it was not supposed to be (our product name doesn't use a capital) and I had to go back and change every occurence of this upper-case letter to a lower-case; which included the project name, core data file, hundreds of variables, etc.

    Anyways, once I had done this I ran into this error and no solution was fixing it for me. I had made sure that all URL names were correct, project cleaned, app uninstalled, phone restarted, etc with no avail. I gave up and turned off my Mac and went home for the day. To my surprise, I came back in this morning and everything seemed to work fine!

    I have no idea why this worked but if your stuck, try restarting your Mac.

提交回复
热议问题