Slow delete and save in nested NSManagedObjectContext

In my application, I have a “main” NSPrivateQueueConcurrencyTypecontext that serves as the parent for the context NSMainQueueConcurrencyTypeon which the view controller relies and controls. I wanted to do this in order to use async saves (this application uses iCloud with Core Data and saves a lot of work on exporting ubiquitous magazines). The setup is similar to the Zarra approach mentioned later in this article.

Saving in an application usually looks like this:

[context save:nil];
[context.parentContext performBlock:^{
     [context.parentContext save:nil];
}];

This seems to work well for small changes / updates, but I'm confused by what I see when I delete a lot of objects (for example, delete a project that has hundreds of task objects associated with it).

In this situation, the save is asynchronous, but it seems that the main thread gets into a semaphore wait situation (as you can see when I pause the debugger) and effectively locks (I cannot scroll in the user interface) until the background is closed, the context completes preservation.

In fact, I just noticed that remote remote deletions of a single object are noticeably delayed despite this asynchronous save template, so it seems that all deletions in the application are slow.

, , NSPrivateQueueConcurrencyType, PSC AppDelegate , - , ( , ).

, , ?

+5
1

. . , .

-, ? , , .

, , FIFO, , , , .

, FRC, , .

, , MOC . , , .

, . , performBlockAndWait. , , . .

GCD, , . , .

+8

All Articles