开发者

Managed Object Model initialization

I am having an issue with core data and I should note that I am using xcode 4.2. I'm getting this error when I try to run my code

***** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Cannot create an NSPersistentStoreCoordinator with a nil model'**

I have traced it down to this line of code in the boilerplate getter given to me by xcode

NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"MyApp" withExtension:@"momd"];
__managedObjectModel = [[NSManagedObjectModel alloc]开发者_运维技巧 initWithContentsOfURL:modelURL];  

Which is returning nil. Now I know I have a manged object model in my supporting files.

Things I have tried so far :

  • Clean the project
  • Reset Content and Settings on the Sim
  • Test on a real device.
  • Restart Xcode


Do you have a file called MyApp.momd (and case matters on the device, though not in simulator) that is included in your "Copy Resources" step? Is modelURL nil, or just managedObjectModel?

You can look in your Simulator directory to see if the file is being copied. Look in ~/Library/Application Support/iPhone Simulator/<version>/Applications/<ID>/MyApp.app. In Finder you would need to use "Show Package Contents" or you can go there using Terminal.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜