So I am trying to get a custom object from core data by setting predicate first then querying the data. Here is what I am doing: NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(dec LIKE[c] %@", [NSNumber numberWithInteger:[tempItemDec integerValue]]];
So the dec is NSNumber and tempItemDec is NSString so I must first convert the string to NSInteger then wrap the integer to NSNumber to be able to query, but it get error saying this:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unable to parse the format string "(dec LIKE[c] %@"'
I am able to query items from the DB if I use their name for example, but this I can’t understand?
Any ideas?
You haven’t closed the parenthesis. Also, you need to supply a string argument for the
LIKEoperator, not a number. Use[NSString stringWithFormat:@"%i", [tempItemDec integerValue]]for example.