Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Haven't tried this myself, but take a look at <code>NSManagedObjectContextWillSaveNotification</code>. I would try registering for those notifications coming from background context. Then in the handler you could do a synchronous dispatch to main thread and pass contexts' deleted object IDs:</p> <pre><code>- (void)handleBackgroundSave:(NSNotification *)note { NSManagedObjectContext *context = [note object]; NSSet *deletedObjectIDs = [[context deletedObjects] valueForKey:@"objectID"]; dispatch_sync(dispatch_get_main_queue(), ^{ // deletedObjectIDs can be passed across threads // if NSFetchedResultsController's fetchedObjects contains deleted objects // you have to disable it and refetch after DidSaveNotification }); } </code></pre> <p>Since the dispatch is synchronous, it should block actual deletion until you deal with it in main thread's context. Keep in mind this wasn't tested and may result in some nasty deadlocks.</p> <p>Another thing worth pointing out is that interactive updates (as in <code>NSFetchedResultsControllerDelegate</code> implementation) will hog UI thread when there's a lot of objects changing (like hundreds/thousands), so if you replace all of your Core Data objects during refresh you may as well disable frc on every WillSave and refetch on every DidSave. </p> <p>If you can afford targeting iOS 5+ then I would suggest exploring nested contexts - <a href="http://www.cocoanetics.com/2012/07/multi-context-coredata/" rel="nofollow">here is a nice overview of approaches</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload