I need to create NSManagedObject
instances, do some stuff with them and then trash them or store to sqlite db. The problem is, I cannot create instances of NSManagedObject
unconnected to NSManagedObjectContext
and this means I have to clear up somehow after I decide that I don't need some of the objects in my db.
To deal with it, I have created an in-memory store using the same coordinator and I'm placing temporary objects there by using assignObject:toPersistentStore.
Now, how do I ensure that these temporary objects don't get to the data, which I fetch from the common to both stores context? Or do I have to create separate contexts for such a task?
UPD:
Now I'm thinking about making separate context for in-memory store. How do I move objects from one context to another? Just using [context insertObject:]? Will it work OK in this setup? If I insert one object from the graph of objects, does the whole graph also get inserted into context?