I realized that the in core data, when you init an NSManagedObjectContext
, NSConfinementConcurrencyType
is deprecated after iOS 9.0. I would like to access NSManagedObjectContext
in my own background queue with concurrency = 1. I know that the Moc of privateQueueConcurrencyType
will create its own queue to execute code and merge to a parent Moc, which seems not what I want. ( mainQueueConcurrencyType
will run the code on main queue which is not what I want either)
Is there anyway that I can manage core data to run in my own background queue?
NSConfinementConcurrencyType
is deprecated. That means you should not use it.
You have two choices.
Access a MOC of NSMainQueueConcurrencyType
on the main queue.
Access a MOC of either NSMainQueueConcurrencyType
or NSPrivateQueueConcurrencyType
from any thread you want, but using the performBlock
and performBlockAndWait
API.
I strongly suggest using the performBlock
API.
Also, using a MOC of NSPrivateQueueConcurrencyType
does not require using a parent/child relationship.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.