I am using NSPredicate to filter the contents of an NSArray of NSDictionary objects. Nothing crazy. I want to check three different values in the dictionary for the same search string. Here is the string I am passing to [NSPredicate predicateWithFormat:]
:
($ECInstanceLabel CONTAINS[c] filterMe) OR (SubLabel1 CONTAINS[c] filterMe) OR (SubLabel2 CONTAINS[c] filterMe)
When I execute this, a valid instance of a new NSPredicate is created, but when I do [NSArray filteredArrayUsingPredicate:]
, the application throws an exception.
The exception is:
'NSInvalidArgumentException', reason: 'Can't get value for 'ECInstanceLabel' in bindings { }.'
I think part of the problem is that my format string specifies that the first dictionary key value is $ECInstanceLabel
but somehow the $
is getting escaped. I have tried manually escaping this character but then the program crashes when I try to create the predicate, so I don't think the $
symbol is recognized as an escapable character.
Any ideas or something obvious I may be missing?
Thanks in advance.