• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Core Data: changes from second MOC not visible main MOC array controller.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Prev by Date: Re: How can I create a PDF document from a string in a non-GUI application?
  • Next by Date: Re: can't get DOMDocument from WebView
  • Previous by thread: Re: Right way to check system version?
  • Next by thread: NSPopUpButtons in tableViews
  • Index(es):
    • Date
    • Thread