Never, ever, use ‘%@’ in CoreData predicates :)
It took me some time to notice that there is a huge difference between
NSPredicate *predicate = [NSPredicate predicateWithFormat: @"(name LIKE '%@')", @"test"];
and
NSPredicate *predicate = [NSPredicate predicateWithFormat: @"(name LIKE %@)", @"test"];
In first case you will end up with predicate like this: name LIKE “%@”, second line will produce correct predicate with %@ replaced with @”test”: name like “test”.
In my opinion this is slightly counter intuitive because ” are automatically added.
September 23rd, 2011 in
main entries