KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have an array of dictionaries. I want to filter the array based on a key. I tried this: NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(SPORT == %@)", @"Football"]; NSArray *filteredArray = [data filteredArrayUsingPredicate:predicate]; This doesn't work, I get no results. I think I'm doing something wrong. I know this is the method if "SPORT" was an ivar. I think it is probably different if it is a key. I haven't been able to find an example however. Thanks Update I added quotes around the string I am searching for. NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(SPORT == '%@')", @"Football"]; It still does not work. Update 2 Solved it. I actually had to remove the single quotes, which seems to go against what the guide says. My real problem is I had a nested array and I wasn't actually evaluating the dictionaries. Bone head move.
Tags (comma-separated)
Save Edits
Cancel