Jor*_*n H 6 core-data ios cloudkit
我正在使用 Core Data 和 CloudKit 构建一个应用程序。我需要检测远程更改何时已推送到应用程序并且可以在本地数据库中使用以对新数据集执行一些工作。我是.NSPersistentStoreRemoteChange这样实现的:
NotificationCenter.default.addObserver(self, selector: #selector(self.storeRemoteChange(_:)), name: .NSPersistentStoreRemoteChange, object: container.persistentStoreCoordinator)
Run Code Online (Sandbox Code Playgroud)
问题是,即使没有从远程 CloudKit 数据库收到更改,也会收到此通知,例如启动应用程序时 4 次,以及对本地数据库进行修改时。我如何才能知道何时从远程数据库收到更改?
虽然我无法仅检测到这种情况,但我确实通过NSManagedObjectContextObjectsDidChangeNotification在触发此通知时利用并执行远程和本地更改处理来满足我的需求。
| 归档时间: |
|
| 查看次数: |
960 次 |
| 最近记录: |