Core Data only migrate specific tables [duplicate]
I have an iPhone app that uses a Core Data database consisting of user data, and app data. I want to update the app data by pushing an update in the app store, but I want to keep the existing user data from the user's current database. Is there any way to "pick and choose" which tables I want to migrate?
There are two things you can migrate / update:
- The model, i.e. the structure of your entities and properties.
- New data that is contained in the model.
As for the migration, you specify which tables are altered and which are not. Where possible, all the data will be preserved automatically. Check out the core data docs about migration, it's pretty straightforward.
As for the data, you can read that in from the app delegate of your new app. Check if the new data is not available (or check if this is the first run after the update), is so, update the table.
精彩评论