Swift3 云工具包如何在出错时重新获取记录
云WWDC会在您获得Swift3 云工具包如何在出错时重新获取记录,swift3,icloud,cloudkit,Swift3,Icloud,Cloudkit,云WWDC会在您获得CKError.changeTokenExpired时通过将以前的服务器更改令牌设置为nil来重新获取更改。我试过这样的方法: let operation = CKFetchRecordZoneChangesOperation() operation.qualityOfService = .userInitiated operation.recordZoneIDs = appDelegate.changedZoneIDs let fetchOptions = CKFetch
CKError.changeTokenExpired
时通过将以前的服务器更改令牌设置为nil来重新获取更改。我试过这样的方法:
let operation = CKFetchRecordZoneChangesOperation()
operation.qualityOfService = .userInitiated
operation.recordZoneIDs = appDelegate.changedZoneIDs
let fetchOptions = CKFetchRecordZoneChangesOptions()
fetchOptions.previousServerChangeToken = nil
operation.optionsByRecordZoneID = [ recordZoneID : fetchOptions]
但是,
选项ByRecordZoneId
已被弃用。那么,如何将上一个服务器令牌传递给服务器,并在错误处理之后继续提取?您应该在CKFetchRecordZoneChangesOperation()上使用实例属性configurationsByRecordZoneID
那么:
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