我的应用程序使用包含在 UIManagedDocument 中的核心数据数据库。当我尝试通过 iCloud 同步时,数据很少被刷新。我通过将以下 app 参数添加到我的方案中来打开普遍存在的日志。
-com.apple.coredata.ubiquity.logLevel 3
参数日志输出显示目标设备在源设备上进行更改后很快就会识别出更改,但NSPersistentStoreDidImportUbiquitousContentChangesNotification
不会触发通知。有时,通知会在看到更新后的很长一段时间内触发,但通常不会。
但是,当我重新启动应用程序时(在日志打印一些有关更改的文本后的任何时间), NSPersistentStoreDidImportUbiquitousContentChangesNotification
通知会立即触发,导致数据刷新。
注意:我已订阅通知。
[[NSNotificationCenter defaultCenter]addObserver:self
selector:@selector(updatedFromCloud:)
name: NSPersistentStoreDidImportUbiquitousContentChangesNotification
object:nil];