I would like to do some calculations and comparisons inside my array
assuming my array is simple as:
NSMutableArray *array;
array = [[NSMutableArray alloc] init];
[array addObject:[NSNumber numberWithInt:1]];
[array addObject:[NSNumber numberWithInt:2]];
[array addObject:[NSNumber numberWithInt:2]];
[array addObject:[NSNumber numberWithInt:3]];
[array addObject:[NSNumber numberWithInt:2]];
What would be an elegant and clever way to check if a number repeats itself 2,3,4 or 5 times inside this array.
(looking for something smart and dynamic….)
You don’t have to loop through things yourself if you just want to know how many times each object shows up. That bit is really easy: