CKError.Code.networkFailure何时会发生?怎么解决呢?

时间:2019-05-22 07:31:59

标签: ios swift cloudkit ckerror

我使用CKQueryOperation从iCloud中获取记录。而且我发现,当我的iPhone的网络环境是蜂窝网络时,则

  

CKError.Code.networkFailure:“可用,但CFNetwork给了我们   错误”。

但是我不知道为什么。这会和我的网络运营商有关吗?

let predicate = NSPredicate(value: true)
    let query = CKQuery(recordType: "RECORD", predicate: predicate)
    query.sortDescriptors = [NSSortDescriptor(key: "modificationDate", ascending: false)]
    let operation = CKQueryOperation(query: query)

// config
let config = CKOperation.Configuration()
config.timeoutIntervalForRequest = 10
config.timeoutIntervalForResource = 10
config.allowsCellularAccess = true
config.qualityOfService = .default
operation.configuration = config
operation.queuePriority = .normal

operation.recordFetchedBlock = { record in
    // handle every record
}
operation.queryCompletionBlock = { (cursor, error) in
    if let error = error {
        // handle error
    } else {
        // succeed
    }
}
self.privateDatabase.add(operation)

0 个答案:

没有答案