Skip to content

Instantly share code, notes, and snippets.

@pbrewczynski
Created December 14, 2013 16:36
Show Gist options
  • Save pbrewczynski/7961497 to your computer and use it in GitHub Desktop.
Save pbrewczynski/7961497 to your computer and use it in GitHub Desktop.
NSCountedSet *nsCountedSet = [[NSCountedSet alloc] initWithArray:@[@"abc",@"abc",@"abc",@"abc",@"other"]];
NSUInteger maxDublication = 0;
NSUInteger actualCount = 0;
for(NSString *s in [nsCountedSet objectEnumerator]) {
actualCount = [nsCountedSet countForObject:s]; // unnecessary checking, I want just array/enumarator of amounts.
if(maxDublication < actualCount) {
maxDublication = actualCount;
}
}
NSLog(@"Max dublication is : %lu", (unsigned long)maxDublication);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment