Skip to content

Instantly share code, notes, and snippets.

@Duraiamuthan
Created September 22, 2013 06:49
Show Gist options
  • Save Duraiamuthan/6657376 to your computer and use it in GitHub Desktop.
Save Duraiamuthan/6657376 to your computer and use it in GitHub Desktop.
Objetctive c format the numbers with commas
NSNumberFormatter *formatter = [[[NSNumberFormatter alloc] init] autorelease];
[formatter setNumberStyle:NSNumberFormatterDecimalStyle];
double d =324233.89;
int i = 324324324;
NSString *strFloat = [formatter stringFromNumber:[NSNumber numberWithDouble:d]];
NSString *strInt = [formatter stringFromNumber:[NSNumber numberWithInt:i]];
NSLog(@"Float: %@", strFloat);
NSLog(@"Int: %@", strInt);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment