How to copy an object between 2 NSManagedObjectContext
How to copy NSManagedObject
from one NSManagedObjectContext
to another?
I have 2 different ones NSManagedObjectContext
, each with its own NSManagedObjectModel
and separate permanent store. Each of the 2 MOCs has an object named Observation
that is tied to the same Observations class.
I want to copy objects from one MOC to another. Since the objects are of the same class, I would like to simply extract the object from one MOC and store it in another. Is this possible, or do I need to insert a new object into the target MOC and then set each property one at a time?
source to share
You need to copy one object and paste a new one into another managed object context. You will most likely have to copy property values ββone at a time to do this.
The reason is that all of these objects have an opaque unique identifier, so you cannot just take it from one context to another.
source to share