This is the case - I'm using a simple UITableView that renders records from the CloudKit publicDB. When I run the app, the query operation returns for example returns 2 results (that's all it has currently).
My table view has a refresh control and when I pull to refresh I got zero results, if I continue to do reloads, eventually a result might come out but now always.
The same thing happens with more results as well, I used to have CKLocation type which I queried and the response was always different without any common sense
Some example code (the predicate in this case is TRUEPREDICATE - nothing fancy):
let sort = NSSortDescriptor(key: "creationDate", ascending: false)
let query = CKQuery(recordType: "Tests", predicate: DiscoveryMode.getPredicate())
query.sortDescriptors = [sort]
var operation = CKQueryOperation(query: query)
if lastCursor != nil {
operation = CKQueryOperation(cursor: lastCursor)
}
operation.resultsLimit = 15
operation.recordFetchedBlock = recordFetchBlock
operation.queryCompletionBlock = { [weak self] (cursor:CKQueryCursor!, error:NSError!) in
if cursor != nil {
self!.lastCursor = cursor
}
dispatch_async(dispatch_get_main_queue(), { () -> Void in
Misc.hideLoadingInView(view: self!.view)
self!.tableView.reloadData()
self!.refreshControl.endRefreshing()
if error != nil {
Misc.showErrorInView(view: self!.view, message: error.localizedDescription)
}
})
}
CloudKit.sharedInstance.publicDB.addOperation(operation)
All the recordFetchBlock does is to add objects to a mutable array that the table view uses as dataSource.
I'm new to CloudKit and I'm puzzled is this by design (not returning all the results but some random) or I'm doing something wrong?