【发布时间】:2015-02-25 13:57:52
【问题描述】:
我有字典数组,字典包含作为 NSString 的键和作为整数的值。我尝试了以下代码,但没有得到结果。
NSPredicate *objPredicate = [NSPredicate predicateWithFormat:@"%@ = %@", key, [NSNumber numberWithInt:value]];
NSArray *filteredArray = [array filteredArrayUsingPredicate:objPredicate];
【问题讨论】:
-
你的字典不能有整数,只有对象可以存储在字典、数组、集合中......你的字典中必须有一个 NSNumber:这可能工作正常:[NSPredicate predicateWithFormat:@ "%@ = %@", 键, 值];
标签: ios objective-c arrays dictionary