CloudKit CKError "Invalid Arguments" 和 "Bad sync continuation data"

CloudKit CKError "Invalid Arguments" with "Bad sync continuation data"

我正在 Xcode 8.3 和 iOS 10 上工作,我按照 Apple 的 Cloud Kit Quick Start 文档维护云数据的本地缓存,我的设备能够接收推送当私有数据库区域中的数据发生更改时收到通知,但在尝试获取区域更改时,我总是会收到以下错误:

2017-06-17 11:58:11.376807-0400 MyApp[10694:5029263] received remote notification
2017-06-17 11:58:11.897402-0400 MyApp[10694:5031532] fetch database change completed
2017-06-17 11:58:11.897606-0400 MyApp[10694:5031532] zone deletions
2017-06-17 11:58:12.320908-0400 MyApp[10694:5031561] record zone fetch completed
Error fetching zone changes for private database: <CKError 0x170256620: "Invalid Arguments" (12/2006); server message = "Bad sync continuation data"; uuid = xxxxxxxx-EFD7-459D-xxxx-xxxxxxxxxxx; container ID = "iCloud.com.mycompany.MyApp">
2017-06-17 11:58:12.332247-0400 MyApp[10694:5031561] fetch record zone changes completed
Error fetching zone changes for private database: <CKError 0x174640150: "Partial Failure" (2/1011); "Couldn't fetch some items when fetching changes"; uuid = xxxxxxxx-EFD7-459D-xxxx-xxxxxxxxxxx; container ID = "iCloud.com.mycompany.MyApp"; partial errors: {
PrivateZone:__defaultOwner__ = <CKError 0x170254670: "Invalid Arguments" (12/2006); server message = "Bad sync continuation data">
}>

"Bad sync continuation data" 非常令人困惑,因为我无法在 Apple 文档中找到对此错误的解释,也无法在 google 搜索中找到任何参考。有人遇到过这个吗?

在进一步思考 "continuation" 在此上下文中的含义并深入研究 Apple 示例后,我意识到问题在于我只为在不同获取更改阶段返回的服务器更改令牌保留了一个变量,由 fetchDatabaseChangesfetchZoneChanges 方法表示。添加变量以跟踪数据库更改令牌和区域更改令牌(每个区域都有自己的)后,"Bad sync continuation data" 错误消失了,我可以看到从服务器返回的更改记录。