Coredata loss all data with CloudKit sometimes

31 Views Asked by At

I have enabled iCloud synchronization in my app, but I may encounter this situation: this morning, I opened the app to record data, and then went to use another app. After a while, when my phone's battery was low, I plugged it into my mbp to start charging, but when I opened my app again, I found that all the data was gone. I had to restart multiple times to trigger iCloud synchronization, but after the synchronization was completed, I would lose the data recorded in the last hour, Dose anyone know why? This situation rarely occurs, and it usually doesn't happen once a month?

Does it matter if my NSPersistentCloudKitContainer initialization has added the following configuration

ctr.viewContext.automaticallyMergesChangesFromParent = true
ctr.viewContext.mergePolicy = NSMergeByPropertyObjectTrumpMergePolicy

0

There are 0 best solutions below