NSManagedObjects in a legacy document
NSManagedObjects in a legacy document
- Subject: NSManagedObjects in a legacy document
- From: Drew McCormack <email@hidden>
- Date: Sun, 2 Jul 2006 17:54:02 +0200
I've got a legacy Cocoa app that uses keyed-archiving for
persistence. I do not want to convert the existing model classes to
Core Data at this point, but I am extending the app with a piece of
completely new code. I would like to use CoreData for the new code,
and embed the managed objects in the current legacy document format.
What I don't want to do is add keyed-archiving methods to my
NSManagedObjects; this seems wasteful, because all the knowledge to
archive the objects is already present in the form of the model. What
I want is that when my document is saved, a few calls to CoreData are
made to convert that part of the object graph into raw data, so that
I can then just add that via keyed-archiving methods to the legacy
document.
So I want a simple way to convert a bunch of NSManagedObjects from an
NSManagedObjectContext into NSData. I thought maybe I could use an in
memory store to do this, but I can't see any way to archive objects.
My only proposal at this time is to setup a temporary file-based
persistent store, save the object graph, and then simply read in the
file as data and add that to the document. Seems a bit roundabout,
but that is all I can think of.
Is there a better approach?
Drew
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden