Skip to content

Commit 4383284

Browse files
author
Reed Es
committed
added explicit merge policy to main context
1 parent cdfb3cf commit 4383284

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Sources/BaseCoreDataStack-container.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,17 @@ extension BaseCoreDataStack {
4545
// ensure viewContext receives changes from saves of backgroundContext
4646
container.viewContext.automaticallyMergesChangesFromParent = true
4747

48+
// in-memory changes will win any conflict
49+
container.viewContext.mergePolicy = NSMergeByPropertyObjectTrumpMergePolicy
50+
51+
// use generational querying, where this context will pin itself to the generation of the database when it first loads data
52+
// NOTE not used until more research is done on whether it's needed
53+
// do {
54+
// try container.viewContext.setQueryGenerationFrom(.current)
55+
// } catch {
56+
// logger.error("\(#function) setQueryGenerationFrom ERROR \(error)")
57+
// }
58+
4859
// NOTE: the following is necessary to fully initialize the development container(s)
4960
// so that a complete deployment to production is possible in CloudKit dashboard.
5061
// NOTE: Both containers need to be deployed to production.

0 commit comments

Comments
 (0)