我试图使用NSPredicate
来过滤NSDictionary
。似乎有一个错误。使用nspredicate进行Nsdictionary过滤
我有这个NSDictionary
:
dict = [[NSDictionary alloc] initWithObjectsAndKeys:translation, @"trans", meaning, @"mean", pronounce, @"pron", theId, @"id", nil];
我要筛选本字典。如果在字典中id
键的值等于passedId
,将其添加到NSArray
:
我用下面的代码:
NSPredicate *filterPredicate = [NSPredicate predicateWithFormat:@"theId == %@", passedId];
NSArray *requiredRows = [[dict allKeys] filteredArrayUsingPredicate:filterPredicate];
给了我这个错误:
'NSUnknownKeyException', reason: '[<__NSCFConstantString 0xada8> valueForUndefinedKey:]: this class is not key value coding-compliant for the key theId.
@iMani,第一行代码呢? – vikingosegundo