I am working on my first iPhone application and I’ve hit a wall. I’m trying to develop a ‘statistics’ page for a three entity relationship. My entities are the following:
Department – Name, Address, Building, etc.
People – Name, Gender (BOOL), Phone, etc
If I have fetched a specific department how do I filter those results and only return people that are Male (Gender == 0)?
If I do
NSLog(@"%d", [department.people count]);
I get the correct number of people in that department so I know I’m in the neighborhood. I know I could re-fetch and modify the predicate each time but with 20+ stats in my app that seems inefficient. Thanks for any advice!
You don’t need to refetch:
Somehow
gender==NOstill looks strange though 😉If copying is too expensive, you could use enumerators instead. E.g.:
… though this would be ideally moved to a suitable category as say
countOfObjectsMatchingPredicate:.