• 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] Background Insertion
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [CoreData] Background Insertion


  • Subject: Re: [CoreData] Background Insertion
  • From: Dave Hayden <email@hidden>
  • Date: Tue, 5 Jun 2007 15:45:42 -0700

On Jun 5, 2007, at 2:55 PM, Marcus S. Zarra wrote:

I wonder if it would be possible to see what notification is being sent? If it is a true notification, then you could perhaps simulate it yourself....

Might be worth exploring just to see if it can be cleaned up a bit.

It sends a NSManagedObjectContextDidSaveNotification when you save, but it turns out that the array controller uses a separate private notification to do the "automatically prepares content": If you catch the "_NSObjectsChangedInManagingContextPrivateNotification" notification, pass it to the other thread and rebroadcast it with the other thread's managed object context as the notification object, it does update the UI. Not that that's any solution, but it shows a bit of what's going on under the hood. Now if we could find the legitimate way to do that..


Another thing that works and may be a bit more kosher: instead of telling the controller to prepareContent after a save, you can insert the the objects from the main thread's managed object context straight into the array controller, avoiding a fetch:

- (void)dataSaved:(NSSet*)list
{
NSEnumerator* enumerator = [list objectEnumerator];
NSManagedObjectID* objectid;

while ( (objectid = [enumerator nextObject]) != nil )
[listController addObject:[managedObjectContext objectWithID:objectid]];

[listController rearrangeObjects];
}


It seems like this would create a duplicate object in the context, but I don't get any complaints when the main thread context is saved on quit and I don't see everything doubled when I open the app next time.

-D

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: [CoreData] Background Insertion
      • From: "Marcus S. Zarra" <email@hidden>
References: 
 >[CoreData] Background Insertion (From: Andrew Kimpton <email@hidden>)
 >Re: [CoreData] Background Insertion (From: Dave Fernandes <email@hidden>)
 >Re: [CoreData] Background Insertion (From: Andrew Kimpton <email@hidden>)
 >Re: [CoreData] Background Insertion (From: "Marcus S. Zarra" <email@hidden>)
 >Re: [CoreData] Background Insertion (From: Andrew Kimpton <email@hidden>)
 >Re: [CoreData] Background Insertion (From: "Marcus S. Zarra" <email@hidden>)
 >Re: [CoreData] Background Insertion (From: Dave Hayden <email@hidden>)
 >Re: [CoreData] Background Insertion (From: "Marcus S. Zarra" <email@hidden>)
 >Re: [CoreData] Background Insertion (From: Andrew Kimpton <email@hidden>)
 >Re: [CoreData] Background Insertion (From: Andrew Kimpton <email@hidden>)
 >Re: [CoreData] Background Insertion (From: "Marcus S. Zarra" <email@hidden>)

  • Prev by Date: Re: [CoreData] Background Insertion
  • Next by Date: NSForegroundColorAttributeName + NSStrokeWidthAttributeName
  • Previous by thread: Re: [CoreData] Background Insertion
  • Next by thread: Re: [CoreData] Background Insertion
  • Index(es):
    • Date
    • Thread