views:

248

answers:

2

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
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
Don't worry! Figured it out, this blog post here (http://sunflower.coleharbour.ca/cocoamondo/2009/06/core-data-migration/) details it nicely.
Joshua
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