Skip to content

Instantly share code, notes, and snippets.

@anlcan
Created August 13, 2014 11:11
Show Gist options
  • Save anlcan/c8f600369bca4acbe5f7 to your computer and use it in GitHub Desktop.
Save anlcan/c8f600369bca4acbe5f7 to your computer and use it in GitHub Desktop.
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