Cloud WWDC说,当您获得CKError.changeTokenExpired
时,可以通过将先前的服务器更改令牌设置为nil来重新获取更改。我尝试过这样的事情:
let operation = CKFetchRecordZoneChangesOperation()
operation.qualityOfService = .userInitiated
operation.recordZoneIDs = appDelegate.changedZoneIDs
let fetchOptions = CKFetchRecordZoneChangesOptions()
fetchOptions.previousServerChangeToken = nil
operation.optionsByRecordZoneID = [ recordZoneID : fetchOptions]
但是optionsByRecordZoneID
已被弃用。那么如何将先前的服务器令牌传递给服务器并继续获取错误处理信息呢?
答案 0 :(得分:0)
您应该在CKFetchRecordZoneChangesOperation()上使用实例属性configurationByRecordZoneID。
怎么样:
let operation = CKFetchRecordZoneChangesOperation()
operation.qualityOfService = .userInitiated
operation.recordZoneIDs = appDelegate.changedZoneIDs
let fetchOptions = CKFetchRecordZoneChangesOperation.ZoneConfiguration()
fetchOptions.previousServerChangeToken = nil
var zoneConfiguration: [CKRecordZone.ID : CKFetchRecordZoneChangesOperation.ZoneConfiguration] = [:]
for zoneID in operation.recordZoneIDs {
zoneConfiguration[zoneID] = fetchOptions
}
operation.configurationsByRecordZoneID = zoneConfiguration