I know that if you change the Core Data model and you have run the app before on the old model that you will get Persistent Store error. How would you handle changes to the Core Data model so you do not get this error? Is there a way to upgrade an old model so that the already saved data is not lost?
+3
A:
Core Data comes with a built-in mechanism to handle changes to your model.
Take a look at the Core Data Model Versioning and Data Migration Programming Guide for details.
weichsel
2010-01-04 09:28:34
I've tried adding a new version to the Data Model, changing it and doing what it says here http://iphonedevelopment.blogspot.com/2009/09/core-data-migration-problems.html but I still get the same error, even though this is supposed to make it work.
Joshua
2010-01-04 11:13:46
Don't worry! Figured it out, this blog post here (http://sunflower.coleharbour.ca/cocoamondo/2009/06/core-data-migration/) details it nicely.
Joshua
2010-01-04 12:30:13
A:
If 10.6 is your baseline OS then you can use lightweight migration, specifically NSInferMappingModelAutomaticallyOption.
The article I wrote is similar and useful if 10.6 is not your baseline OS.
Matthieu Cormier
2010-01-18 16:48:47