I was wondering if it was possible to search for a CKRecord by not only its record type but as well as its field in the database. For example heres my code I have now to fetch records:
database.performQuery(query, inZoneWithID: nil, completionHandler: { (records:[AnyObject]!, error:NSError!) in
// Check if there's an error
if error != nil {
NSLog(error.localizedDescription)
}
else {
}
})
This only searches through the record type and for my program I need to be able to go deeper and specify a field as well to search through. Any help will be greatly appreciated!
The CKQuery documentation shows you how to build more complex queries. Here is a simple example:
let firstName = "John"
let age = 20
let predicate = NSPredicate(format: "firstName = %@ AND age >= %@", firstName, NSNumber(integer: age))
let query = CKQuery(recordType: "Employee", predicate: predicate)