Search code examples
objective-ccore-data-migrationnscoding

How to convert <NSCoding> Objects to CoreData?


I have a custom class, say the class Person, which implements the NSCoding protocol. I used to save my application's data using:

[NSKeyedArchiver archiveRootObject:{an array containing my Person objects} toFile:pathToSave];

Now I want to switch to CoreData and Cocoa bindings. I think I know the very basics of CoreData, but I don't know how I can import my old unarchived Array into CoreData....

Can someone help me with this or send me a link to a tutorial?

Thanks a lot! Nick


Solution

  • AFAIK there is no way to automagically turn your archived objects to Core Data.

    This article is a good start to what you should do:

    http://www.mentalfaculty.com/mentalfaculty/Blog/Entries/2010/4/17_Keyed-Archiving_to_Core_Data_Migration.html

    In a nut shell, you will replace your <NSCoding> compliant subclasses with NSManagedObject subclasses and do the migration manually.