Suchi
Suchi

Reputation: 10039

iOS - what is the right way to deal with a data model change?

I already have an app in the app store. I want to do an upgrade. My local data store has changed, with an extra table, and with a few fields added in the existing table. I want to retain the data in the old tables. How would I go about doing that? Could someone point me to tutorials that handle that kind of change?

Upvotes: 3

Views: 223

Answers (2)

JoeCortopassi
JoeCortopassi

Reputation: 5093

Check out Apple's docs on migrating a core data instance. They make it super easy for 90% of the cases. The basic idea, is you break you xdatamodel into versions, so it has a path for migration

Here's a tutorial that might help you Core Data Migration

Upvotes: 2

Owen Hartnett
Owen Hartnett

Reputation: 5935

Assuming you're using SQLite: Use a new database with a different name for your update. On startup, check for the table with the old name, copy the data you want, and delete it when you're done.

CoreData has it's own update data which may or may not work for you. You should look into how to change the data model.

Upvotes: 3

Related Questions