我有一个带有词典的可变阵列。我想算一下有多少字典有特定价值?
NSDictionary * question = [self.tabQuestionnaire objectAtIndex:indexPath.row]; [question objectForKey:@“theme”]
答案 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;
}