我有一个NSDictionary,其中包含(我的自定义)GTPerson对象.GTPerson有一个NSMutableSet *parents
属性,我使用@property
和@synthesize
.
在我的NSDictionary之外,我想过滤掉所有没有父母的GTPerson对象,即父母的数量是0.
我正在使用以下代码:
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"parents.count = 0"];
NSArray *np = [[people allValues] filteredArrayUsingPredicate:predicate];
Run Code Online (Sandbox Code Playgroud)
当我执行此操作时,我收到以下错误:
[<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.'
为什么它试图调用count
GTPerson而不是它的parents
属性?