CloudKit 中的 RecordType 是 100 多条记录。以下代码仅从这 11 条记录中获取,它们不是前 11 条记录,它们是从记录的开头、中心和结尾随机选择的。我无法理解代码中有什么问题。
编辑:我通过将 .reseltsLimit 更改为 5000 来实现它!
let cloudContainer = CKContainer.default()
let publicDatabase = cloudContainer.publicCloudDatabase
let predicate = NSPredicate(value: true)
let query = CKQuery(recordType: "Sijainti", predicate: predicate)
var queryOperation = CKQueryOperation(query: query)
queryOperation.queuePriority = .veryHigh
queryOperation.resultsLimit = 50
queryOperation.desiredKeys = ["Koordinaatit"]
queryOperation.recordFetchedBlock = { (record) -> Void in
self.sijainnitArray.append(record)
}
queryOperation.queryCompletionBlock = { (cursor, error) -> Void in
if error != nil {
print("Failed to get data")
return
}
if cursor != nil {
let newQueryOperation = CKQueryOperation(cursor: cursor!)
newQueryOperation.cursor = cursor
newQueryOperation.resultsLimit = queryOperation.resultsLimit
newQueryOperation.queryCompletionBlock = queryOperation.queryCompletionBlock
queryOperation = newQueryOperation
publicDatabase.add(queryOperation)
return
}
}
publicDatabase.add(queryOperation)