我有字典数组,字典包含键作为NSString,值作为整数。我尝试了以下代码但没有得到结果。
NSPredicate *objPredicate = [NSPredicate predicateWithFormat:@"%@ = %@", key, [NSNumber numberWithInt:value]];
NSArray *filteredArray = [array filteredArrayUsingPredicate:objPredicate];
答案 0 :(得分:1)
使用此:
NSPredicate *objPredicate = [NSPredicate predicateWithFormat:@"self[%@] = %@", key, @(value)];
NSArray *filteredArray = [array filteredArrayUsingPredicate:objPredicate];