Cannot create an NSPersistentStoreCoordinator with a nil model

前端 未结 27 1099
囚心锁ツ
囚心锁ツ 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 had exactly the same error message as the original post. I was wrestling with this for hours. It was this line in my AppDelegate.m.

    NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"[same with name of xcdatamodeld]" withExtension:@"momd"];
    

    For anyone out there searching this error message and finding this thread....try this first.

    You must make sure that where it says [same with name of xcdatamodeld]....that it is!!! For some reason, mine had my project name in there and not the data model name.

    Changed it and it worked straight away.....

    Thanks to Rock & Muller for contributing.......you saved me days!!

    Gaz.

提交回复
热议问题