[英]Why can't I query CloudKit from Xcode or CloudKit Dashboard?
When I try to query CloudKit from CloudKit Dashboard, I get an error that says: 当我尝试从CloudKit仪表板查询CloudKit时,出现错误消息:
There was a problem querying the “Entry” type. 查询“条目”类型时出现问题。
no auth method found 找不到身份验证方法
When I try to query the same records from code in Xcode, I get the error message from the error object in my queryCompletionBlock property of my query operation: 当我尝试从Xcode中的代码查询相同的记录时,我从查询操作的queryCompletionBlock属性中的错误对象获取错误消息:
The operation couldn't be completed. 该操作无法完成。 (CKErrorDomain error 4.) (CKErrorDomain错误4。)
Where do I find what error 4 means? 在哪里可以找到错误4的含义?
Here is the code that printed the error message in debug window: 这是在调试窗口中打印错误消息的代码:
let predicate = NSPredicate(value: true)
let query = CKQuery(recordType: DatabaseNameStrings.recordTypeEntry, predicate: predicate) // DatabaseNameStrings.recordTypeEntry = "Entry"
let sortDescriptor = NSSortDescriptor(key: DatabaseNameStrings.recordFieldKeyCreationDate, ascending: true)
query.sortDescriptors = [sortDescriptor]
let queryOperation = CKQueryOperation(query: query)
queryOperation.database = container.privateCloudDatabase
queryOperation.desiredKeys = [DatabaseNameStrings.fieldNameText] // DatabaseNameStrings.fieldNameText = "text"
queryOperation.recordFetchedBlock = {
(record: CKRecord) in
let entry = Entry(ckRecord: record)
self.entries.append(entry)
}
queryOperation.queryCompletionBlock = {
(cursor: CKQueryOperation.Cursor?, error: Error?) in
if let error = error {
print(error.localizedDescription) // The operation couldn’t be completed. (CKErrorDomain error 4.)
} else {
DispatchQueue.main.async {
self.tableView.reloadData()
}
if let cursor = cursor {
let innerQueryOperation = CKQueryOperation(cursor: cursor)
innerQueryOperation.desiredKeys = queryOperation.desiredKeys
innerQueryOperation.recordFetchedBlock = queryOperation.recordFetchedBlock
innerQueryOperation.queryCompletionBlock = queryOperation.queryCompletionBlock
queryOperationQueue.addOperation(queryOperation)
} else {
DispatchQueue.main.async {
self.tableView.reloadData()
}
}
}
}
queryOperationQueue.addOperation(queryOperation)
它开始工作,我没有做任何修复。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.