NSPredicate: "Unable to parse the format string '%@'"?

core-data, ios, nspredicate, objective-c, predicate

Solution

`%@` is not a predicate format, it's a string format.

NSPredicate *pred = [NSPredicate predicateWithFormat:predString];

Problem

I'm trying to build a query string or predicate but I keep getting this error, Basically what I can't understand is that this works fine: ``` NSPredicate *pred = [NSPredicate predicateWithFormat:@"(name contains[cd] 'o')"]; ``` But this: ``` NSString *predString = @"(name contains[cd] 'o')"; NSPredicate *pred = [NSPredicate predicateWithFormat:@"%@", predString]; ``` throws this: `*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unable to parse the format string "%@"'`

Original source