Thanks, Rob. I do have this book, but I sort of skipped the section about multithreading (where the export example is buried), but I've found it now.

Thanks to the others who replied as well. I think this has set me on the right track.

@Jerry: I chose not to use a document-based design because I want all the meetings and categories to be available as a list in the app, rather like Mail.app with mailboxes and messages. Then a 'normal' core- data app seemed more appropriate to me.

Martin

On Nov 9, 2009, at 3:23 AM, Rob Keniger wrote:


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/martin.hewitson%40aei.mpg.de

This email sent to [email protected]

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Martin Hewitson
Albert-Einstein-Institut
Max-Planck-Institut fuer
    Gravitationsphysik und Universitaet Hannover
Callinstr. 38, 30167 Hannover, Germany
Tel: +49-511-762-17121, Fax: +49-511-762-5861
E-Mail: [email protected]
WWW: http://www.aei.mpg.de/~hewitson
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~





_______________________________________________

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