问题
In CloudKit RecordType is more than 100 records. Following code gets from these only 11 and they are not first 11 records, they are picked randomly from beginning, center and at the end of records. I can't get whats wrong in code.
EDIT : I got it working by changing .reseltsLimit to 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)
来源:https://stackoverflow.com/questions/40847040/cloudkit-ckqueryoperation-doesnt-get-all-records