CloudKit: can not build
| Originator: | kaskaaddnb | ||
| Number: | rdar://18798061 | Date Originated: | 29-Oct-2014 00:34 AM |
| Status: | Duplicate of 13348715 (Open) | Resolved: | |
| Product: | iOS | Product Version: | iOS 8+ |
| Classification: | Serious Bug | Reproducible: | Always |
Summary:
I would like to create a subscription, which will send me notifications when record will be updated, but only that record which has non-empty `inviteCode` string field. Since there is no proper documentation about the restrictions for NSPredicate in comparison to Core Data's one, I spent hours to debug the problem, using well worked Core Data predicates as well some really fantastic ones. The results are listed below:
1. Predicate: NSPredicate * sPredicate = [NSPredicate predicateWithFormat:@"inviteCode != nil"];
Result: Error with description: "Expected constant value in comparison expression: inviteCode != nil"
2. Predicate: NSPredicate * sPredicate = [NSPredicate predicateWithFormat:@"length(inviteCode) > 0"];
Result: Crash with description: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unable to parse function name 'length:' into supported selector (length:) '
3. Predicate: NSPredicate * sPredicate = [NSPredicate predicateWithFormat:@"inviteCode.lenght > 0"];
Result: Error with description: recordKey (inviteCode.lenght) contains invalid characters
4. Predicate: NSPredicate * sPredicate = [NSPredicate predicateWithFormat:@"inviteCode != \"\""];
Result: no errors in completion block, but subscription does not send any notifications after record with non-empty 'inviteCode' field gets updated.
Steps to Reproduce:
You must save "MyRecord" record with non-empty string field "myStringField" on either public or private database.
NSString * sID = @"subscription ID";
NSPredicate * sPredicate = [NSPredicate predicateWithFormat:@"myStringField != nil"];
CKSubscription * s = [[CKSubscription alloc] initWithRecordType:@"MyRecord" predicate:sPredicate subscriptionID:sID options:CKSubscriptionOptionsFiresOnRecordUpdate];
CKNotificationInfo *note = [[CKNotificationInfo alloc] init];
note.alertLocalizationKey = @"Notification text";
s.notificationInfo = note;
[database saveSubscription:s completionHandler...];
Expected Results:
The subscription created on a server and it will detect all updates of "MyRecord" records which field "myStringField" is not an empty string.
Proper documentation about all CloudKit's NSPredicate-related restrictions!
Actual Results:
Error with description: "Expected constant value in comparison expression: stringField != nil"
Version:
iOS 8+
Notes:
Configuration:
iPhone 5
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!