0

I am saving multiple fields in different records in CloudKit. When I query the records I currently have them sorted by creation date. Am I able to sort these records by the Date/Time fields I have my users save to the record and not by the creation or modification date of the records?

@objc func queryDatabaseColby() {
    let query = CKQuery(recordType: "ColbyFlight", predicate: NSPredicate(value: true))
    database.perform(query, inZoneWith: nil) { (records, _) in
        guard let records = records else {return}
        let sortedRecords = records.sorted(by: { $0.creationDate! > $1.creationDate! })
        self.colbyFlight = sortedRecords
        DispatchQueue.main.async {
        }
    }
}
rmaddy
  • 314,917
  • 42
  • 532
  • 579
BlueBulls
  • 11
  • 2

1 Answers1

0

Replaced sorted by creation date with sorted by: value(forKey: "date") and got it to do what I want.

BlueBulls
  • 11
  • 2