CloudKit“订阅重复”错误 - 获取SubscriptionId

时间:2017-12-05 22:17:40

标签: ios cloudkit ckquery ckerror

我正在尝试将CKQuerySubscription保存到公共数据库 - 返回CKError并提供以下信息:

[
    "ServerErrorDescription": subscription is duplicate of 'C82E82EF-F373-4D75-A465-65364D8FEB12',
    "CKErrorDescription": Error saving record subscription with id E30DB4D5-2617-4E0D-8CFE-A14538140029 to server: subscription is duplicate of 'C82E82EF-F373-4D75-A465-65364D8FEB12',
    "NSDebugDescription": CKInternalErrorDomain: 2032,
    "NSUnderlyingError": <CKError 0x1c064ec70: "Server Rejected Request" (2032); server message = "subscription is duplicate of 'C82E82EF-F373-4D75-A465-65364D8FEB12'"; uuid = A5290A31-650C-44FC-B1C1-7BCB181291F8; container ID = "iCloud.com.mycompany.myapp">, 
    "NSLocalizedDescription": Error saving record subscription with id E30DB4D5-2617-4E0D-8CFE-A14538140029 to server: subscription is duplicate of 'C82E82EF-F373-4D75-A465-65364D8FEB12', "errorKey": ck1uc5yob, 
    "RequestUUID": A5290A31-650C-44FC-B1C1-7BCB181291F8, 
    "ContainerID": iCloud.com.mycompany.myapp
]

ancestorRecord对象上的属性clientRecordserverRecordCKError都是nil

如何从此错误中获取服务器上存在的查询的ID(即C82E82EF-F373-4D75-A465-65364D8FEB12)。是否有我失踪的财产?

1 个答案:

答案 0 :(得分:1)

有几种选择。我倾向于使用fetchAllSubscriptionsWithCompletion处理程序来提取所有订阅,然后解析我感兴趣的订阅,如下所示:

 [publicDatabase fetchAllSubscriptionsWithCompletionHandler:^(NSArray<CKSubscription *> * _Nullable subscriptions, NSError * _Nullable error)
 {  
     for (CKQuerySubscription *sub in subscriptions)
     {
         NSString *predString = [NSString stringWithFormat:@"%@", sub.predicate];
     }
 }];

但您也可以使用CKFetchSubscriptionsOperation根据订阅ID提取所有潜艇或特定潜艇。在这种情况下,您将创建操作,配置您感兴趣的订阅ID,将后处理代码添加到完成块,然后运行然后运行操作。