Use NSCountedSetand then find the object with the highest counter using the method countForObject:.
NSCountedSet *setOfObjects = [[NSCountedSet alloc] initWithArray:yourArrayhere];
NSString *mostOccurringObject = @"";
NSUInteger highestCount = 0;
for (NSString *strObject in setOfObjects)
{
NSUInteger tempCount = [setOfObjects countForObject:strObject];
if (tempCount > highest)
{
highestCount = tempCount;
mostOccurringObject = strObject;
}
}
Verification of the result:
NSLog(@"Most frequent string: %@ with count: %i", mostOccurringObject,highestCount);
@Evan Mulawski