1

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?

Matt W.
  • 956
  • 9
  • 21

1 Answers1

1

There are two things you can migrate / update:

  1. The model, i.e. the structure of your entities and properties.
  2. 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.

Mundi
  • 79,884
  • 17
  • 117
  • 140
  • Can you be more specific in the last sentence when you say "update the table"? How do I specifically tell the app to only update one table? Because my database is a resource in my app. – Matt W. Aug 21 '11 at 17:16
  • No, normally you have a database that is a resource in your app, but in order to modify it, you need to copy it to the **application user directory**. You can put the new data into a file, sqlite or serial, in the app resources bundle, and then read it in and copy it to the existing persistent store. Clear? – Mundi Aug 21 '11 at 17:31