gpt4 book ai didi

ios - 如何使用 previousServerchangetoken 初始化 CKFetchRecordZoneChangesOperation?

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:05:41 26 4
gpt4 key购买 nike

我正在从 CloudKit 服务器获取记录更改,但每次我都会出错

[LogFacilityCK] Got a connection error for operation E0367CA861DAF5A9: Error Domain=NSCocoaErrorDomain Code=4097 "connection to service named com.apple.cloudd" UserInfo={NSDebugDescription=connection to service named com.apple.cloudd}

我知道原因是我错误地初始化了 CKFetchRecordZoneChangesOperation请检查以下代码并纠正我:

 CKFetchRecordZoneChangesOperation  *operation = [[CKFetchRecordZoneChangesOperation alloc]initWithRecordZoneIDs:@[ recordZoneID ] optionsByRecordZoneID:@{@"Zone":recordZoneID,@"FetchRecordZoneChangesOptions":option}];

我需要这部分的帮助:

**@{@"Zone":recordZoneID,@"FetchRecordZoneChangesOptions":option}];**

最佳答案

简单地创建变量:

var serverChangeToken: CKServerChangeToken? {

guard let encoded = UserDefaults(suiteName: SharedGroupName)?.data(forKey: ServerChangeTokenKey) else {
return nil
}

return NSKeyedUnarchiver.unarchiveObject(with: encoded) as? CKServerChangeToken
}

然后初始化一个对象:

        let zone = CKRecordZone(zoneName: "my_custom_zone_name")
let options = CKFetchRecordZoneChangesOptions()
options.previousServerChangeToken = serverChangeToken

let operation = CKFetchRecordZoneChangesOperation(recordZoneIDs: [zone.zoneID], optionsByRecordZoneID: [zone.zoneID: options])

关于ios - 如何使用 previousServerchangetoken 初始化 CKFetchRecordZoneChangesOperation?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42160429/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com