Creating Background Thread for Core Data writing

前端 未结 2 1486
忘掉有多难
忘掉有多难 2021-01-03 07:57

I\'m trying to recreate the three tier core data system that is described in this cocoanetics article ( http://www.cocoanetics.com/2012/07/multi-context-coredata/). The prob

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-03 08:53

    The easiest way to perform Core Data operations in the background is to create a managed object context of the NSPrivateQueueConcurrencyType. This type of MOC creates and manages a private queue. Using performBlock or performBlockAndWait to execute operations on the private MOC ensures that the right queue is used.

    See Concurrency Support for Managed Object Contexts in the Core Data Release Notes for OS X v10.7 and iOS 5.0 for details and examples.

    I can only recommend to watch the video or slides from the WWDC 2011 Session 303 "What’s New in Core Data on iOS", where Core Data concurrency is explained.

提交回复
热议问题