I have an NSDictionary which contains (my custom) GTPerson objects. GTPerson has an NSMutableSet *parents
attribute, on which I use @property
and @synthesize
.
Out of my NSDictionary, I want to filter all the GTPerson objects which don't have any parents, i.e. where the count of parents is 0.
I'm using the following code:
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"parents.count = 0"];
NSArray *np = [[people allValues] filteredArrayUsingPredicate:predicate];
When I execute this, I receive the following error:
[<GTPerson 0x18e300> valueForUndefinedKey:]: this class is not key value coding-compliant for the key count.
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<GTPerson 0x18e300> valueForUndefinedKey:]: this class is not key value coding-compliant for the key count.'
Why is it trying to call count
on GTPerson and not on its parents
attribute?