objective-c - 何时需要将 NSManagedObjectContext 与 NSMainQueueConcurrencyType 一起使用

标签 objective-c cocoa core-data nsmanagedobjectcontext

我有一个 NSPersistentDocument,我正在将其默认 MOC 替换为具有 NSPrivateQueueConcurrencyType 的 MOC,这可以很好地保持操作脱离主线程。

但是,我是否还需要使用 NSMainQueueConcurrencyType 创建一个子 MOC?如果需要的话,它的用途是什么?

最佳答案

Apple 关于此主题的文档不是很明确,也不是最新的。核心数据编程指南指出:core data programming guide

The pattern recommended for concurrent programming with Core Data is thread confinement: each thread must have its own entirely private managed object context. [...] You must create the managed context on the thread on which it will be used.

关于objective-c - 何时需要将 NSManagedObjectContext 与 NSMainQueueConcurrencyType 一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17517742/

相关文章:

objective-c - TableView 中的 QLPreviewPanel 存在问题 : "has no controller"

ios - 如何在OS X应用程序中重置内容和设置?

ios - Swift 3 核心数据问题 - 所有数据丢失

iphone - 在 UIScrollView 上添加多个 MPMoviePlayerController?

ios - 将数据从 ViewController 传递到 AppDelegate

cocoa - 如何使用 NSWorkspace 打开文件类型? - cocoa

macos - 阻止 OpenGL.framework 在 Cocoa 应用程序中加载

objective-c - NSManagedObject子类和xcdatamodeld文件之间有什么关系?

ios - 可以将 "self"与 NSSortDescriptor 一起使用以按对象本身而不是对象的属性进行排序吗? (核心数据/NSFetchedResultsController)

iOS - 在容器 View 中交换 View Controller 并保存数据