When loading items from CloudKit I would like to order the results by creation date. I believe now it's sorting by the first property of the record.
func loadItems() {
let predicate = NSPredicate(value: true)
let query = CKQuery(recordType: "Items", predicate: predicate)
db.performQuery(query, inZoneWithID: nil) { (results, error) -> Void in
if error != nil {
println(error.localizedDescription)
}
dispatch_async(dispatch_get_main_queue()) { () -> Void in
items = results as [CKRecord]
self.tableView.reloadData()
println("items: \(items)")
}
}
}
This is what I was looking for:
query.sortDescriptors = [NSSortDescriptor(key: "creationDate", ascending: false)]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With