相关疑难解决方法(0)

NSPersistentStoreRemoteChangeNotification 没有被解雇

我正在尝试在我的 CoreData+CloudKit 项目中执行历史跟踪,该项目使用NSPersistentCloudKitContainer. 我一直在关注 Apple 的示例项目

我想在远程存储更新后执行某些任务。为此,苹果建议在应用程序的签名和功能的后台模式部分启用远程通知。

我已经为我的项目启用了历史跟踪,如 Apple 的示例项目所示。

    // turn on persistent history tracking
    let description = container.persistentStoreDescriptions.first
    description?.setOption(true as NSNumber,
                           forKey: NSPersistentHistoryTrackingKey)

    // ...
Run Code Online (Sandbox Code Playgroud)

我还注册了我的商店来监听商店的变化。

    // turn on remote change notifications
    let remoteChangeKey = "NSPersistentStoreRemoteChangeNotificationOptionKey"
    description?.setOption(true as NSNumber,
                               forKey: remoteChangeKey)

    // ...
Run Code Online (Sandbox Code Playgroud)

还添加了观察者来侦听NSPersistentStoreRemoteChangeNotification.

然而,没有NSPersistentStoreRemoteChangeNotification被解雇。为了确保我的实现没有错误,我只是在@objc func storeRemoteChange(_ notification: Notification)Apple 提供的示例代码中放置了断点,但我仍然看不到任何通知被触发并且没有断点被激活。

我已经了解示例项目中完成的标签重复数据删除,也尝试对其进行测试,但没有任何成功。这是 Apple 实现中的错误还是我缺少任何必需的设置?

core-data cloudkit ios13 nspersistentcloudkitcontainer

12
推荐指数
2
解决办法
2545
查看次数