Why does the former of following snippets work while not the latter ?
Snippet 1
NSPredicate *predicate = [NSPredicate predicateWithForma
I got the following error even though my NSPredicate was formatted correctly.
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Insufficient arguments for conversion characters specified in format string.' site:stackoverflow.com
Like a fool I forgot to pass a second argument to the predicate format (because there were two %@
). I.e. NSPredicate(format:predicateFormat,argumentArray:[Date()])
has only one element in the array when it needs to be two: [Date(), Date()]
coin_unique
is a key, so it needs the %K
format specifier:
NSString *predicateText = @"coin_unique";
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(%K == %@)", predicateText, [NSNumber numberWithInt:species]];
The format syntax is described quite well here.