Created
August 13, 2014 11:11
-
-
Save anlcan/c8f600369bca4acbe5f7 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 * formatString(NSString * input){ | |
// ### ### ## ## | |
if ( [input length] > 8){ | |
return [NSString stringWithFormat:@"%@ %@", | |
formatString([input substringToIndex:8]), | |
[input substringFromIndex:8]]; | |
} else if ( [input length] > 6){ | |
return [NSString stringWithFormat:@"%@ %@", | |
formatString([input substringToIndex:6]), | |
[input substringFromIndex:6]]; | |
}else if ( [input length] > 3){ | |
return [NSString stringWithFormat:@"%@ %@", | |
[input substringToIndex:3], | |
[input substringFromIndex:3]]; | |
}else | |
return input; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment