【发布时间】:2016-10-04 15:47:35
【问题描述】:
以前在应用程序中,我使用多上下文方法来使用后台上下文对后台线程中的数据进行操作。就这样完成了。
// backgroundContext in the background thred
lazy var backgroundContext: NSManagedObjectContext? = {
let coordinator = self.store.persistentStoreCoordinator
var backgroundContext = NSManagedObjectContext(concurrencyType: .PrivateQueueConcurrencyType)
backgroundContext.persistentStoreCoordinator = coordinator
return backgroundContext
}()
它是这样使用的:
self.coreDataManager.saveContext(self.coreDataManager.backgroundContext!)
使用新的 CoreData 更新,我们应该如何处理多个 CoreData 上下文?因为现在有了NSPersistentContainer,它应该以另一种方式处理。
【问题讨论】:
-
你试过
newBackgroundContext()的方法吗?
标签: ios swift core-data swift3