Copying objects between CoreData stores
Copying objects between CoreData stores
- Subject: Copying objects between CoreData stores
- From: Rick Mann <email@hidden>
- Date: Tue, 03 Jan 2012 23:32:06 -0800
I'm working on a Core Data-based CAD app. The schema includes Parts and PartInstances. There is a to-many relationship from Part to PartInstance. The Library contains Parts, but a CAD file contains Parts and PartInstances.
When the user creates a new PartInstance in a document, I need to copy the Part object from the Library to the document. This is not just a copy from one NSManagedObjectContext to another, it's also a copy from one peristent store to another. That's fine.
But when the user instantiates a new PartInstance of the same Part again, this time I don't want to copy the Part over, because it already exists. I need a way to determine if the Part object already exists in the document's MOC.
I can create a UUID of sorts to use, but I'm wondering if I can do something to create the new object (in the new persistent store) with the same objectID as the object from which it's coming. That makes it much easier to then check for the existence of that object in the new store/context before creating it. Note that I have several other entities in the overall schema, and it would be nice not to have to add a uuid to each of those, as well.
Any recommendations?
Thanks,
Rick
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden