【发布时间】:2014-02-06 12:34:27
【问题描述】:
我正在尝试使用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,第一行代码呢?
标签: ios objective-c nsdictionary nspredicate