Reasonably new CloudKit. Can anyone please tell me why the below fails to return any records? If I comment out the query.sortDescriptors I get my records. The deployment is set to iOS 15.0. It's probably staring me in the face but I just can't see it :(
class func GetContactRecords(){
StaticVarHelpers.ClearContacts()
let query = CKQuery(recordType: "Contacts", predicate: NSPredicate(value: true))
query.sortDescriptors = [NSSortDescriptor(key: "contact", ascending: true)]
CloudHelpers.dataBase.perform(query, inZoneWith: nil) { ( records, _) in
guard let records = records else {return}
print("Contacts Total Records = \(records.count)")
for BD in records{
StaticVarHelpers.ContactsNotes.append(BD.value(forKey: "contactNotes") as! String)
StaticVarHelpers.ContactsContactNo.append(BD.value(forKey: "contactNumber") as! String)
StaticVarHelpers.ContactsContact.append(BD.value(forKey: "contact") as! String)
}
}
}
CodePudding user response:
Found it... In the CloudKit Console >>> Schema >>> Indexes >>> Contacts, I forgot to add 'contact' as Sortable.