I am following Apples Core Data Tutoriol but implementing it into my own Project, this means I've not started by creating a Project using Core Storage Data. So I've been copying and pasting quite a lot of the stuff that should of been automatically made for me, and I have run into a problem.
I am getting this error:
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[NSURL 开发者_开发技巧initFileURLWithPath:]: nil string parameter'
Which happens in this function:
- (NSManagedObjectModel *)managedObjectModel {
if (managedObjectModel_ != nil) {
return managedObjectModel_;
}
NSString *modelPath = [[NSBundle mainBundle] pathForResource:@"Assignments" ofType:@"momd"];
NSURL *modelURL = [NSURL fileURLWithPath:modelPath];
managedObjectModel_ = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL];
return managedObjectModel_;
}
I have my data model in the Resources Group and its named "Assignments.xcdatamodel" so I'm stuck on what the problem is.
I am thinking in some configuration file I need to change something, or perhaps its just a simple path mistake?
Any help is much appreciated.
If you have a single version of the object model in your project you may need to use "mom" as the extension instead of "momd". Give it a try and see if it helps!
I believe the name of your project, not the name of the datamodel should go in pathForResource
.
精彩评论