2
以前在应用程序中,我使用多上下文方法来使用后台上下文来处理后台线程中的数据。它是这样做的。Swift 3.0 CoreData创建多上下文
// 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()'方法吗? –