Created
May 15, 2011 18:43
-
-
Save yanks/973419 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSString* truncateString(NSString* input) | |
{ | |
NSCountedSet* set = [[NSCountedSet alloc] init]; | |
for( int i = 0; i < [input length]; i++ ){ | |
[set addObject:[NSString stringWithFormat:@"%c", [input characterAtIndex:i]]]; | |
} | |
NSMutableString* result = [[NSMutableString alloc] init]; | |
for( NSString* key in set ){ | |
[result appendString:key]; | |
if( [set countForObject:key] > 1 ){ | |
[result appendString:key]; | |
} | |
} | |
[set release]; | |
return [result autorelease]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment