0

I have a app in app store, but now I added new attribute to entity. How can I update user's entity without deleting app and lose data?

Thanks

PatrikD
  • 379
  • 4
  • 16
  • possible duplicate of [Implementation of "Automatic Lightweight Migration" for Core Data (iPhone)](http://stackoverflow.com/questions/2310216/implementation-of-automatic-lightweight-migration-for-core-data-iphone) – Lars Blumberg Aug 18 '14 at 11:03
  • Make sure you do so in a new version of the datastore and a new version of the the app. iOS should handle the migration. – wottle Aug 18 '14 at 11:09
  • I added new version i update storeURL but my core data is empty. Do you have any examples of migration datas? – PatrikD Aug 18 '14 at 11:35

1 Answers1

1

1) Click on your xcdatamodel file in Xcode
2) Choose the menu Editor in the upper bar
3) Click on Add version model
4) Create a new model based on the previous one
5) Perform your updates in the new created xcdatamodel file

The app will automatic handle your updates

David Bemerguy
  • 1,334
  • 11
  • 15
  • Yes but I wanna migration data I used lightweight migration I write function but can you help me with it? storeURL it is new version or old? http://pastebin.com/fDymKbX9 – PatrikD Aug 18 '14 at 11:17
  • The steps I wrote are for data migration. When adding a new xcdatamodel version, the sdk will handle the old data and get it to the new model, which has more columnds and etc. – David Bemerguy Aug 18 '14 at 12:20
  • I dont understand I done everything. But when I run app again with new version it show me only error `Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayI objectAtIndex:]: index 0 beyond bounds for empty array'` – PatrikD Aug 18 '14 at 12:27