Why does this predicate returns results:
predicate= [NSPredicate predicateWithFormat:@"itemsString like '*{4160366}*'"];
while this predicate returns empty array
predicate= [NSPredicate predicateWithFormat:@"itemsString like '*{%@}*'",[NSString stringWithString:@"4160366"]];
I’s driving me crazy
When building a predicate, predicateWithFormat automatically adds quotes when performing variable substitution. So your (second) predicate ends up looking like this:
itemsString like '*{"4160366"}*'".Notice the extra set of quotes.
Change it to:
and it should work.
(Note that instead of using
stringWithStringI just used@""which does the same thing.)