Core Data: changes from second MOC not visible main MOC array controller.
Core Data: changes from second MOC not visible main MOC array controller.
- Subject: Core Data: changes from second MOC not visible main MOC array controller.
- From: "Diederik Hoogenboom (Eetay)" <email@hidden>
- Date: Fri, 19 May 2006 13:17:17 +0200
I have the following:
- main Managed Object Context (MOC) with an array controller bound to
this MOC.
- thread that inserts MO's in a second MOC. undo registration
disabled for this MOC.
Creating second moc:
NSManagedObjectContext *mainContext = [self managedObjectContext];
NSManagedObjectContext *threadContext = [[NSManagedObjectContext
alloc] init];
[threadContext setPersistentStoreCoordinator:[mainContext
persistentStoreCoordinator]];
[[threadContext undoManager] disableUndoRegistration];
Currently as a test I am only inserting one MO in the second MOC:
NSManagedObject *newObject = [NSEntityDescription
insertNewObjectForEntityForName:@"ObjectTest"
inManagedObjectContext:threadContext];
[newObject setValuesForKeysWithDictionary:someDictionary];
After inserting I save the second MOC and notify the main MOC of the
changes:
NSError *error;
if (![threadContext save:&error])
[[NSApplication sharedApplication] presentError:error];
else {
// make main MOC aware of new MO
[mainContext objectWithID:[newObject objectID]];
}
[threadContext release];
However the changes are not visible in the tableview bound to the
array controller. When I do the inserting using the main MOC
everything works fine.
Instead of objectWithID: I have also tried refreshObject:
mergeChanges: with no result.
When I reload my application the (saved) data is displayed fine.
Am I missing something?
Diederik
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden