Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSManagedObjects in a legacy document



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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.