NSmutableArray与字典值如何计算具体值?

时间:2011-09-22 13:15:42

标签: xcode dictionary nsmutablearray tableview

我有一个带有词典的可变阵列。我想算一下有多少字典有特定价值?

NSDictionary * question = [self.tabQuestionnaire objectAtIndex:indexPath.row]; [question objectForKey:@“theme”]

1 个答案:

答案 0 :(得分:1)

- (NSInteger)countValue :( NSString *)值forKey:(NSString *)key {

NSInteger result = 0;

 for (NSDictionary *question in self.tabQuestionnaire){
    if ([value isEqualToString: [question objectForKey:key]]){
       result++;
 }

return result;

}