2

I am struggling with an issue related to Core Data.

In my app, I use Core Data for storing and retrieving the values. In my latest version, I added some attributes to entities from the old version. I updated the app from the App Store, and when I click on the page where we need to display the contents from Core Data, it is crashing.

If the old version of the app is removed and the new one is downloaded, then it doesn't crash.

My requirement is any alternative there is to fix without having to remove the old version of the app (merging the old version with the new version).

Any suggestions on how to fix this issue?

Thanks in advance.

SpacePyro
  • 3,121
  • 4
  • 25
  • 30
Vidhyanand
  • 993
  • 10
  • 21
  • The [apple docs](https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CoreDataVersioning/Articles/Introduction.html) on CoreData versioning are a pretty good start. – David Berry Apr 18 '14 at 15:11
  • Related: http://stackoverflow.com/questions/1018155/what-do-i-have-to-do-to-get-core-data-to-automatically-migrate-models – Matthias Bauch Apr 18 '14 at 15:19

2 Answers2

3

Did you setup versioning of core data? IF so, in your Xcode project navigator, your .xcdatamodeld should be drop down with multiple .xcdatamodeld underneath it. And then in attribute inspector with the parent .xcdatamodeld selected you pick your current version.

If the changes are minor, this will take care of it's self when you load new app version ontop of older version.

If the changes are major, you need to setup handling for this in your app delegate to tell the app how to move data between the two versions.

Augie
  • 1,341
  • 1
  • 11
  • 18
1

You have to migrate the Core Data store from the old Version to the new one.

This tutorial show's how this works: http://www.raywenderlich.com/27657/how-to-perform-a-lightweight-core-data-migration

HackingOtter
  • 134
  • 6