On 09/11/2009, at 5:18 AM, Martin Hewitson wrote:

> I've been digging around for export and import strategies to allow me to 
> export parts of a core data model. In more detail, I have a set of 
> categories, each of which contains a set of meetings. Each meeting has a 
> fairly complex object graph below it (agenda, agenda items, location, title, 
> etc). I want to allow the user to export a meeting which can then be imported 
> by someone else using the same application.
> 
> Does anyone have any good advice how best to approach this? I was considering 
> making the NSManagedObject subclasses conform to NSCoding, but I read in a 
> couple of places that this was difficult to do, particularly the 
> initWithCoder: part. Anyone tried this already?


Yes, I've done this. What I did is create a second NSManagedContext with a 
separate NSPersistentStore and copy the relevant objects out of the main 
NSManagedContext into the new one. You basically do the reverse on import.

There is an excellent example of how to handle import and export in Marcus 
Zarra's Core Data book:

http://pragprog.com/titles/mzcd/core-data

I highly recommend getting a copy if you're working with Core Data.

--
Rob Keniger



_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to