I have a model file thats named "Model". If I rename it to "SomeOtherName" it just does not get loaded.
initWithContentsOfURL
returns nil and:
mergedModelFromBundles: [NSArray arrayWithObjects:[NSBundle mainBundle], nil];
...crashes with because it thinks there is nil in this array.
I am allowed to rename my model so whats wrong? I can not give you more info because I have none :P The SomeOtherName model is placed in the bundle and it should load just fine.
Thanks
I just ran into the same problem. Here is how I solved it:
Renaming the model file alone is not enough, because it does not rename the reference to the current model version.
It turns out the model version is stored in a separate plist file. Simply open it in a text editor and change the old name to your new model file name.
File: YourNEWModelFile.xcdatamodeld/.xccurrentversion
<plist version="1.0">
<dict>
<key>_XCCurrentVersionName</key>
<string>YourModelFile.xcdatamodel</string> <-- Change this to YourNEWModelFile
</dict>
</plist>
Please note that you should only do this if you rename the model file during development. For migrating your data model to a new version, follow the Core Data docs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With