目前,我们正在使用本地CoreData功能CloudKit,通过使用NSPersistentCloudKitContainer.
由于/sf/answers/5078817971/中描述的问题,我们需要启用NSPersistentHistoryTrackingKey.
基于https://developer.apple.com/documentation/coredata/consuming_relevant_store_changes,我们应该手动执行持久历史记录清除。
但是,目前尚不完全清楚我们如何以安全的方式清除历史记录,而不影响 的正确性CloudKit。我们倾向于使用以下设置运行一些测试。
@objc func storeRemoteChange(_ notification: Notification) {
// Process persistent history to merge changes from other coordinators.
historyQueue.addOperation {
self.processPersistentHistory()
}
}
/**
Process persistent history, posting any relevant transactions to the current view.
*/
private func processPersistentHistory() {
backgroundContext.performAndWait {
// Fetch history received from outside the app since the last token
let …Run Code Online (Sandbox Code Playgroud)