• 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
Re: CoreData: NSManagedContext not updating NSArrayController in UI
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CoreData: NSManagedContext not updating NSArrayController in UI


  • Subject: Re: CoreData: NSManagedContext not updating NSArrayController in UI
  • From: mmalcolm crawford <email@hidden>
  • Date: Mon, 21 Nov 2005 13:36:21 -0800


On Nov 21, 2005, at 12:59 AM, Marc Monguio wrote:
I'm trying to update the main moc (NsManagedObjectcontext *) with the new values inserted from another moc in another thread. I want an NSArrayController to show the moc's new registered values in the interface

The "BackgroundFetching" example in <file:///Developer/Examples/ CoreData/> shows how to do this.

- (void)updateManagedObjectContext:(NSNotification *)aNotification;
{
NSManagedObject *insertedObject;
NSSet *registeredObjects = [moc registeredObjects];
NSSet *insertedObjects = [[aNotification userInfo] objectForKey:NSInsertedObjectsKey];
while ((insertedObject = [enumerator nextObject]) != nil) {
//this should register the insertedObject from the other thread to the main moc
staleObject = [moc objectWithID:[insertedObject objectID]];
//to be sure I refresh it, it doesn't work either...
[moc refreshObject:staleObject mergeChanges:NO];
//to be sure I save, it doesn't work either...
[moc save:&error];


It's not clear why you would want to refresh or save an object you've just retrieved?


So what I'm doing is populate the main moc that is also used in the NSArrayController. But the NSArrayController doesn't show the new inserted values in the UI unless I ask for a fetch:
- (void)updateManagedObjectContext:(NSNotification *)aNotification;
{
[myArrayController fetch:self];
}


Have you set the "Automatically prepares content" switch for the controller?

<http://developer.apple.com/documentation/Cocoa/Conceptual/CoreData/ Articles/cdTroubleshooting.html#//apple_ref/doc/uid/TP40002320- DontLinkElementID_69>

mmalc

_______________________________________________
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


References: 
 >CoreData: NSManagedContext not updating NSArrayController in UI (From: Marc Monguio <email@hidden>)

  • Prev by Date: Looking for an engineer with Cocoa and CoreData prog. experience
  • Next by Date: Re: adding Foundation framework to a Carbon application
  • Previous by thread: Re: CoreData: NSManagedContext not updating NSArrayController in UI
  • Next by thread: [ANN] MKSplitView 0.1
  • Index(es):
    • Date
    • Thread