DataManagement: Load background context after persistent store

Removes the CoreData warning on startup.

Signed-off-by: kingbri <bdashore3@gmail.com>
This commit is contained in:
kingbri 2022-08-08 12:17:56 -04:00
parent 24b86335d5
commit 6a90dab386

View file

@ -36,15 +36,16 @@ struct PersistenceController {
container.viewContext.mergePolicy = NSMergeByPropertyObjectTrumpMergePolicy
try? container.viewContext.setQueryGenerationFrom(.current)
backgroundContext = container.newBackgroundContext()
backgroundContext.automaticallyMergesChangesFromParent = true
backgroundContext.mergePolicy = NSMergeByPropertyObjectTrumpMergePolicy
try? backgroundContext.setQueryGenerationFrom(.current)
container.loadPersistentStores { _, error in
if let error = error {
fatalError("CoreData init error: \(error)")
}
}
backgroundContext = container.newBackgroundContext()
backgroundContext.automaticallyMergesChangesFromParent = true
backgroundContext.mergePolicy = NSMergeByPropertyObjectTrumpMergePolicy
try? backgroundContext.setQueryGenerationFrom(.current)
}
func save(_ context: NSManagedObjectContext? = nil) {