CKModifyRecordsOperation ModifyRecordsCompletionBlock没有被调用 [英] CKModifyRecordsOperation modifyRecordsCompletionBlock not being called

查看:96
本文介绍了CKModifyRecordsOperation ModifyRecordsCompletionBlock没有被调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 CKModifyRecordsOperation 保存一组记录,如果我可以连接互联网,那么一切正常,正在调用完成块。但是,当我没有连接时,不会调用完成块,也不会收到任何有关我的操作失败的信息。

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;
};

然后我正在使用

[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?

推荐答案

CloudKit操作的 qualityOfService 属性设置为 NSQualityOfServiceUtility 默认情况。

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

使用 NSQualityOfServiceUtility NSQualityOfServiceBackground 可能被标记为使用自主网络请求。如果网络连接状况不佳,系统可以保留任意的网络请求,因此您可能无法从服务器获得响应,直到情况改善并且系统发送请求为止。

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.

如果想要在所有情况下立即发送您的请求,请将 CKOperation.qualityOfService 设置为 NSQualityOfServiceUserInitiated NSQualityOfServiceUserInteractive

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

这篇关于CKModifyRecordsOperation ModifyRecordsCompletionBlock没有被调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆