$var
is used in predicates for variables that can be substituted later.
If you have a key containing $
or other special characters then use the %K
expansion:
[NSPredicate predicateWithFormat:@"(%K CONTAINS[c] %@) OR (SubLabel1 CONTAINS[c] %@) OR (SubLabel2 CONTAINS[c] %@)",
@"$ECInstanceLabel", searchTerm, searchTerm, searchTerm]
And use the %@
format for the search term instead of writing it inline, to avoid
errors if the search term contains special characters.
Of course you can use %@
for all keys, but in this case you need it only for
the first key that contains special characters.