I working on iOS app implementing cloudkit but I need to query all the records with ID greater then a number. For example I have record with ID of 23:
here is my code:
CKContainer *myContainer = [CKContainer containerWithIdentifier:containerID];
CKDatabase *publicDatabase = [myContainer publicCloudDatabase];
CKRecordID *recordID = [[CKRecordID alloc] initWithRecordName:@"23"];
CKReference* recordToMatch = [[CKReference alloc] initWithRecordID:recordID action:CKReferenceActionNone];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"recordID >= %@", recordToMatch];
CKQuery *query = [[CKQuery alloc] initWithRecordType:recordType predicate:predicate];
[publicDatabase performQuery:query inZoneWithID:nil completionHandler:^(NSArray *results, NSError *error) {
if (error) {
NSLog(@"error: %@", error.localizedDescription);
}
else {
}
}];
But I'm getting the following error:
error: error: The operation couldn’t be completed. (CKErrorDomain error 1.)
Any of you knows how can I setup my NSPredicate in a way where I can get all the records with ID greater then 23 ?
I'll really appreciate your help.
For a query like this you could use a predicate like:
in Swift:
In Objective C:
Then I do assume that you created the CKRecords object originally while specifying this number. Otherwise recordID values will be assigned by CloudKit and will be a GUID.