Set merge policy on managed object contexts and maybe fix some CoreData errors?
This commit is contained in:
parent
6bc4993d81
commit
f5953655c5
|
@ -26,6 +26,7 @@ class MastodonCachePersistentStore: NSPersistentContainer {
|
|||
let context = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
|
||||
context.persistentStoreCoordinator = self.persistentStoreCoordinator
|
||||
context.automaticallyMergesChangesFromParent = true
|
||||
context.mergePolicy = NSMergePolicy.mergeByPropertyObjectTrump
|
||||
return context
|
||||
}()
|
||||
|
||||
|
@ -33,6 +34,7 @@ class MastodonCachePersistentStore: NSPersistentContainer {
|
|||
let context = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
|
||||
context.persistentStoreCoordinator = self.persistentStoreCoordinator
|
||||
context.automaticallyMergesChangesFromParent = true
|
||||
context.mergePolicy = NSMergePolicy.mergeByPropertyObjectTrump
|
||||
return context
|
||||
}()
|
||||
|
||||
|
@ -62,6 +64,7 @@ class MastodonCachePersistentStore: NSPersistentContainer {
|
|||
}
|
||||
|
||||
viewContext.automaticallyMergesChangesFromParent = true
|
||||
viewContext.mergePolicy = NSMergePolicy.mergeByPropertyObjectTrump
|
||||
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(managedObjectsDidChange), name: .NSManagedObjectContextObjectsDidChange, object: viewContext)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue