Reputation: 65
I'm trying to import large amout of data according to this solution. It is suggested that each importing threads should have its own managedObjectContext
and they cannot pass any managedObject
among them. So, my question is how we can set the relationship if two objects was created in different MOCs?
PS: After saving MOC in thread, it notifies the main MOC to merge the contexts. So related object for new object is always located in main MOC. In other words related object has already been created.
Upvotes: 0
Views: 210
Reputation: 5346
You can't pass NSManagedObject
s between threads, but you can pass NSManagedObjectID
s.
Pass those over, and then retrieve the objects themselves from the context that you want to set the relationship within.
Upvotes: 2