I am getting this error when entering a keyword in my searchbox:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unable to parse the format string "(title CONTAINS[c] 'hj'"
I enter any string ('hj' in this case) followed by an apostrophe (or containing an apostrophe ). No apostrophe - no error.
This is what I did:
(void)filter:(NSString*)keyword{
NSString* predicateString = [NSString stringWithFormat:@"(title CONTAINS[c] '%@')", keyword];
NSPredicate *predicate = [NSPredicate predicateWithFormat:predicateString];
self.filteredArray = [self.initialArray filteredArrayUsingPredicate:predicate];
}
As I said, the code works if apostrophe character is not included in keyword.