my NSManagedObjectModel is returning nil eventhough the path is correct.
NSString *modelKey = [NSString stringWithFormat:@\"/%@/Model\", name];
N
I just encountered this issue after changing the case of the name of the .xcdatamodeld file (e.g. refactored "mydatastore.xcdatamodeld" to "MyDatastore.xcdatamodeld") on a case-insensitive filesystem.
The fix includes both of the above answers:
Refactor the data model file to a distinctly different name, e.g. "MyDatastoreTemporary.xcdatamodeld"
Product > Clean
Close XCode. Re-open XCode and the project.
Refactor the data model file back to its final name, e.g. "MyDatastore.xcdatamodeld"
Product > Clean
Close XCode. Re-open XCode and the project.
When I ran the project the first time, I specified the extension as xcdatamodeld. But that failed since, it should be momd. But I passed a nil instead of momd assuming extension won't be mandatory. But with nil, the initWithContentsOfURL failed and when I finally entered momd,it worked fine.
The by far safest way, if you have not yet versioned your model, is to do the following.
contents. Copy this file into the same location under your newly named ?.xcdatamodeld/?.xcdatamodel directory.This works with basic models that have no versions.
I had the same problem after I renamed .xcdatamodeld file. The problem was solved by closing and reopening the Xcode client.
I tried both of the above answers, however what fixed it for me was removing and re-adding the .xcdatamodeld file from/to the Xcode project. No cleaning was necessary. For some reason adding it back seems to fix the problem.
I resolved the problem moved to trash the model .xcdatamodeld and then added it one more time.