I'm attempting to search an array of objects using NSPredicate. The objects have a number of NSString properties that I want to filter.
I have the following code to do the filtering:
NSString *predicateString = [NSString stringWithFormat:@"name like[c] %@",self.textFieldOutlet.text];
NSPredicate *searchPredicate = [NSPredicate predicateWithFormat:predicateString];
NSArray *results = [[MySingleton sharedMySingleton].cardArray filteredArrayUsingPredicate:searchPredicate];
But I get the following error:
WebKit discarded an uncaught exception in the webView:shouldInsertText:replacingDOMRange:givenAction: delegate: <NSUnknownKeyException> [<CardObject 0x14a530> valueForUndefinedKey:]: this class is not key value coding-compliant for the key test.
If I put single quotes around the %@
it works but only if the entered text is exactly the same as the value held for the name key and not if it is 'like' the value. Thus not very useful. I must be doing something wrong with the predicate string, can anyone advise?
Thanks in advance!