CKModifyRecordsOperation modifyRecordsCompletionBlock not being called

▼魔方 西西 提交于 2019-12-10 13:45:33

问题


I'm using CKModifyRecordsOperation to save a set of records and if I have internet connection all works well and completion block is being called. But when I don't have connection the completion block is not being called and I don't get any information that my operations failed.

I'm using the following code in completion block

modifyOperations.modifyRecordsCompletionBlock = ^(NSArray *savedRecords, NSArray *deletedRecordIDs, NSError *error)
{
    if(error){
        NSLog(@"Error: %@", error.localizedDescription);
    }

    item.creatorRecordId = record.recordID;
};

and then I'm performing operation using

[self.publicDB addOperation:modifyOperations];

Any ideas how can I get an information if the operation failed for example in the case where there is no internet connection?


回答1:


CloudKit operations have their qualityOfService property set to NSQualityOfServiceUtility by default.

Operations that use NSQualityOfServiceUtility or NSQualityOfServiceBackground may be marked as using discretionary network requests. The system can hold discretionary network requests if network connectivity is poor, so you might not get a response from the server until conditions improve and the system sends the request.

If you'd like your request to be sent immediately in all cases, set CKOperation.qualityOfService to NSQualityOfServiceUserInitiated or NSQualityOfServiceUserInteractive.



来源:https://stackoverflow.com/questions/34239774/ckmodifyrecordsoperation-modifyrecordscompletionblock-not-being-called

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!