我需要一种办法,计算在任何特定可移动的阿雷拉发生物体的多少时间,然后将物体的索引归还给一枚可持久、可移动的阿雷。 我尝试了这样做的两重方式,但必须加以说明。
So basically say I have an array containing 2,3,3,4,3,5,3 When searching for 3, it should give me both the number of times, 4, and a seperate array containing 1,2,4,6 (the indexes of the objects.
I saw the following code already here on the site, but cant work out how to modify it, can anyone help me?
int occurrences = 0;
for(NSString *string in array){
occurrences += ([string isEqualToString:@"Apple"]?1:0); //certain object is @"Apple"
}