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()'方法嗎? –