I have two instances NSManagedObjectContext: one is used in the main thread, and the other is used in the background thread (via NSOperation.) For thread safety, these two contexts are used only NSPersistentStoreCoordinator.
The problem I encountered is pending changes in the first context (in the main thread), which are not available in the second context until executed -save. This is understandable, because in the general store with persistent storage will not be stored up NSManagedObjects, monitored -insertedObjects, -updatedObjectsand -deletedObjects.
Unfortunately, this creates a problem with the user interface: any unsaved changes will not be displayed in reports (time) that are generated in the background thread.
The only solution I can think of is unpleasant: take the inserted, updated, and deleted objects from the first context and transfer them to the object graph of the second context. The data set has a rather complicated relationship, so I hesitate to go in that direction. I hope someone here will be a better solution.
source
share