2

我现在正在使用CKQueryOperation和CKModifyRecordsOperation来处理我在cloudKit中的记录。我发现无论我使用蜂窝还是wifi,有时都很好,但有时操作会出现超时,CKError.Code = 4。这是我的代码:

let operation = CKModifyRecordsOperation(recordsToSave: [record], recordIDsToDelete: [])

    let config = CKOperation.Configuration()
    config.timeoutIntervalForRequest = 10
    config.timeoutIntervalForResource = 10

    operation.configuration = config
    operation.queuePriority = .veryHigh
    operation.modifyRecordsCompletionBlock = { [unowned self] (resultRecords, resultRecordIDs, error) in
        DispatchQueue.main.async {
            UIApplication.shared.isNetworkActivityIndicatorVisible = false
        }
        if let error = error {
            DispatchQueue.main.async {
                self.delegate!.failedWithError(error)
            }
        } else {
            let resultDevice = Device(record: resultRecords!.first!)
            self.deviceList.insert(resultDevice, at: 0)
            DispatchQueue.main.async {
                self.delegate!.succeedWithOperationMode(DeviceModel.OperationMode.insert, indexes: [])
            }
        }
    }
    privateDatabase.add(operation)
    UIApplication.shared.isNetworkActivityIndicatorVisible = true

任何帮助,将不胜感激。

4

0 回答 0