Working on the Main Queue

In general, working on the main queue hasn’t changed from the original design. Assuming you’re working with an NSManagedObjectContext that’s configured to run on the main queue, you’d access that NSManagedObjectContext the exact same way as before.

The big difference is when your code is on another queue and you need to do some data work on the main queue. Getting that work onto the main queue has changed, fortunately for the better. This improvement is in the form of two methods: -performBlock: and -performBlockAndWait:.

Introducing -performBlock:

The goal of -performBlock: is to guarantee that a block of code is being executed on the correct queue, which is the queue that the NSManagedObjectContext is associated ...

Get Core Data in Objective-C, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.