0

My app currently uses NSCoding to store persistent data, but I would like to make the switch to Core Data to take advantage of its integration with iCloud. The problem is that the app is currently live on the App Store, and I'm afraid that, once I make the change, the data on my current users' local stores will be lost.

In theory, I should be able to do the following:

  1. Test for existence of NSCoding data
  2. Convert data to Core Data format
  3. Use Core Data for all future "saves"

... but I haven't found any documentation on making the conversion.

Any ideas? Or am I totally off somewhere?

Thanks

roadkill
  • 315
  • 1
  • 2
  • 12

1 Answers1

1

CoreData does some nice automated migration, but that's from different CoreData stores. In your case, you will have to write your own conversion code.

Leave the "old" classes around, and unarchive the "old" store if it is there. Then, just loop through the objects in the store, and create their CoreData equivalents. Save the CoreData, close it, then reload it as a check to make sure everything is identical. Then, delete the old storage file.

The only down side is that you have to keep old code around (at least enough to unarchive the old object formats).

Jody Hagins
  • 27,943
  • 6
  • 58
  • 87