Reputation: 2941
I have a CoreData app in which I have two NSNanagedContext
:s for concurrency. One for the main thread and one for my background thread.
In one of my view controllers I also have a separate NSOperationQueue
, which I use like this:
[self.queue addOperationWithBlock:^{
[self processDataFromDictionary:jsonObject];
[...]
I've noticed that my NSNanagedContext also have a perform block method. If I instead wrote:
[self.backgroundContext performBlock:^{
[self processDataFromDictionary:jsonObject];
Would that also be executed asynchronously?
Upvotes: 0
Views: 135
Reputation: 126137
If your managed object context is created using appropriate concurrency type, calling performBlock from any other queue will cause the block to be executed asynchronously on the context's own queue.
Upvotes: 1