为什么CKFetchRecordsOperation不起作用?

时间:2020-03-17 14:16:16

标签: swift cloudkit

此操作不检索任何内容。没有调用CkFetchRecordsCOmpletion块吗?感谢您的宝贵时间!

public func getRecord(recordID: CKRecord.ID, completion: @escaping (CKRecord?, CKError?) -> Void) {
    let operation = CKFetchRecordsOperation(recordIDs: [recordID])
    operation.fetchRecordsCompletionBlock = { (records, error) in
        // Checking for potential errors
        if let error = error {
            completion(nil, error as? CKError)
            print(error)
        }

        if let record = records?[recordID] {
            completion(record, nil)
        }
    }

    operation.qualityOfService = .utility
    let privateDatabase = CKContainer(identifier: "something").privateCloudDatabase
    privateDatabase.add(operation)
}

0 个答案:

没有答案