Working off the Main Queue

Now that threading with Core Data has been reduced to a binary question, the other type of NSManagedObjectContext we’ll look at is NSPrivateQueueConcurrencyType.

The primary difference between the two context types is what queue the context is associated with. When you’re working with an NSMainQueueConcurrencyType context, the context automatically associates itself with the main queue. When you initialize an NSPrivateQueueConcurrencyType context, the context will associate itself with a non-main queue that’s private to the context.

Private means that you can’t access that queue directly. Calling dispatch_sync or dispatch_async on that queue is against the API. The only way to interact with a private queue context ...

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.