CoreData: could not locate an NSManagedObjectModel for entity name
If you've gone through Apple's Core Data Tutorial for iOS and gotten this error message after trying to copy that functionality into your existing app:
+entityForName: could not locate an NSManagedObjectModel for entity name
you might need to modify the line of code in your application delegate where you load the managed object model.
NSString *modelPath = [[NSBundle mainBundle] pathForResource:@"AppName"
ofType:@"momd"];
The steps you're taken through in the tutorial put your object models in an xcdatamodeld directory, whereas if you just add a model to an existing project it goes in an xcdatamodel file. During the build process, xcdatamodeld directories get converted to momd files, but xcdatamodel files by themselves get turned into mom files.
You can fix the problem in two ways:
- Change the filename you're opening to be of type mom
- Select your model file and go to Design --> Data Model --> Add Model Version. XCode will place your model file and a new model file in a xcdatamodeld directory. Then delete the extra model version until you really need it.
CoreData,
iOS,
iphone,
sdk in
programming
Reader Comments