Post

Replies

Boosts

Views

Activity

NSPersistentCloudkitContainer setup - merge behavior - contexts
Is it ok to use automaticallyMergesChangesFromParent to true for a managed object context that pins its query generation to current? I have heard from a few sources that in most cases, it’s not recommended to set automaticallyMergesChangesFromParent to true for a managed object context that pins its query generation to current. A source I have seen says: When you pin a managed object context to a specific query generation, you’re explicitly telling the context to view the data as it existed at the time of that generation token (often referred to as a snapshot). This ensures that the context is isolated from any subsequent changes made by other contexts or background tasks. But this may Conflict with Automatic Merging because: The purpose of setting automaticallyMergesChangesFromParent to true is to have the context automatically merge changes from the parent (e.g., background or main context) into itself whenever the parent context saves changes. This behavior conflicts with the concept of a pinned query generation because: • If the context is pinned to current, it should not be concerned with changes that happen after that pinning. • Automatic merging would introduce updates from the parent context that occur after the pinning, thereby violating the “snapshot” nature of the query generation and potentially creating inconsistencies. However, in your own Apple Sample Code Titled "" does use both together. Inside the definition of lazy var persistentContainer: NSPersistentCloudkitContainer the following code is included: // Pin the viewContext to the current generation token, and set it to keep itself up to date with local changes. container.viewContext.automaticallyMergesChangesFromParent = true do { try container.viewContext.setQueryGenerationFrom(.current) } catch { fatalError("###\(#function): Failed to pin viewContext to the current generation:\(error)") }
Topic: UI Frameworks SubTopic: General
0
0
276
Oct ’24
Core data & CloudKit public database sync
I can’t seem to get the code to sync the public cloudkit database with core data to work. Having followed along very closely with the WWDC video that supposedly should help us get it to work, I still cannot get the program to work as expected. It doesn’t work the way the WWDC lecture says it should. It leaves out some steps, misrepresents others, and overall is not good enough as an instructional method. Why not have an actually operable project of some type that prospective adopters of this technology can utilize. There is so little documentation about how to go about doing it and some of the documentation is contradictory or misleading. I am resorting to trial and error and attempting to read core data and cloudkit console output to make it work. I can’t tell you how frustrating it is that Apple, who created this technology, does such a poor job of helping people adopt it. Try and create the project the way the video does. Trying to make sense of it and fit the pieces together that the video leaves out is very difficult. In the future do a better job of centralising the instructional tools for new tech. Make sure they are consistent and easy to find. And please help me with the syncing a Core Data store to the public database until you do so. Sincerely, Derek Pickett
0
0
494
Sep ’20