I am trying to write a NSPredicate
to fetch userID and claimID and I am getting the below error.
Terminating app due to uncaught exception NSInvalidArgumentException', reason: 'Unable to parse the format string "claimID != '' & userID = %@"'
My Code is-
+(NSArray*)fetchNotificationsWithPredicate {
NSPredicate *predicate=[NSPredicate predicateWithFormat:@"claimID != '' & userID = %@",[[NSUserDefaults standardUserDefaults] objectForKey:@"usernmae"]];
NSLog(@"%@",[self fetchNotifications]);
NSArray *loginUsers = [DBUtils createAndExecuteFetchRequestWithPredicate:@"Notification" predicate:predicate];
return loginUsers;
}
Looking at the predicate string format, it looks like &
isn't a valid operator. You either want AND
or &&
. So:
@"claimID != '' && userID = %@"
or
@"claimID != '' AND userID = %@"
(This may well not be the only issue. I've never used this API, and I'm not an iOS developer. This is just from inspection of the documentation...)
See more on this question at Stackoverflow