I've been hitting this problem with coredata and it's driving me nuts because it should be straight forwards
I'm currently working on the first release of this app, os obviously I keep tweeking the core data model here and there,
However each time change the core data model I need to uninstall the application and reinstall the new version.
This is passable while its just me, but once released I need to be able to change update the app without my users reinstalling.
What am I missing,
Is there some code I need to write to tell core data how to modify the existing persistant data to the new one ?
THanks for your help
Jason
You need to read up on Core Data versioning and migration. Here's a blog post that explains it well:
http://www.timisted.net/blog/archive/core-data-migration/
Core data model - migration - adding new attributes/fields to current data model - no RESET of simulator or app required
Steps:
1) Create Model version from editor - Give it any meaningful name like ModelVersion2
2) Go to that model version and make changes to your model.
3) Now go to YourProjectModel.xcdatamodeld and set current version to newly created version.
4) Add below code to place where you are creating persistent coordinator -
and set options value as options for method -
In my case, it looks something like this:
Link: http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CoreDataVersioning/Articles/vmInitiating.html#//apple_ref/doc/uid/TP40004399-CH7-SW1