如何检查数组中有多少次重复项。我有一个包含重复项目的数组。下面是数组。计算每个值在数组中重复的次数
"Family:0",
"Family:0",
"Family:0",
"Gold:3",
"Gold:3"
所以,我想对各个项目的回应值3和2。我怎样才能做到这一点。希望我明确我的观点。如果有任何不清楚的地方请问。
下面是我试过的代码。
int occurrences = 0;
int i=0;
for(NSString *string in arrTotRows){
occurrences += ([string isEqualToString:[arrTotRows objectAtIndex:indexPath.section]]); //certain object is @"Apple"
i++;
}
看到我的答案.... –