I am searching an array of custom items using the following NSPredicate:
NSPredicate *query = [NSPredicate predicateWithFormat:@"[%K contains[cd] %@", column, searchString];
The array contains items of a custom class that has a number of variables (column specifies the one that is supposed to be searched). This works great for the variables that are NSStrings, however, there are some that are ints or doubles, and this code crashes when it trys to sort these. Is there any way to sort a list of ints or doubles?
Post the code that fills the array.
Post the crash.
Post how you are trying to evaluate the predicate against the array.
If the answer to (1) is that you are sticking ints/doubles directly into the array, that won’t work; they need to be objects. If the answer to (2) is an unrecognized selector sent to an NSNumber/NSValue class, then you need to convert the #s to strings for
contains[cd]to work.