I have a data model which has values of type id that I was planning on开发者_C百科 casting appropriately when needed.
Is it possible for me to cast these as strings and compare them to strings from a UISearchBar using NSPredicate or do I have to use another method?
Maybe something like this:
NSPredicate * predicate;
predicate = [NSPredicate predicateWithFormat:@"CAST(%K) contains[cd] %@", employeeID , theSearchBar.text];
No. The CAST()
function doesn't work that way. I think you just have to assume that the id
returned from -employeeID
is comparable to a string.
精彩评论