• 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: Jim Correia <email@hidden>
  • Date: Mon, 21 Nov 2005 07:17:22 -0500

On Nov 21, 2005, at 3:59 AM, Marc Monguio wrote:

- (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];
}
}

If you have simply inserted objects in another moc, then they aren't stale in this moc, since they've never been registered. Your loop should be using objectRegisteredForID: and only refreshing those (so as to not pull in objects that no one wasn't already paying attention to.


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];
}

As far as I know, this is the only way to get your controller to react to insertions/deletions in another moc.


Jim
_______________________________________________
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


  • Follow-Ups:
    • Re: CoreData: NSManagedContext not updating NSArrayController in UI
      • From: Marc Monguio <email@hidden>
References: 
 >CoreData: NSManagedContext not updating NSArrayController in UI (From: Marc Monguio <email@hidden>)

  • Prev by Date: An extremely weird slowness...
  • Next by Date: Saving 1-bit TIFF images
  • Previous by thread: CoreData: NSManagedContext not updating NSArrayController in UI
  • Next by thread: Re: CoreData: NSManagedContext not updating NSArrayController in UI
  • Index(es):
    • Date
    • Thread