Created
September 22, 2013 06:49
-
-
Save Duraiamuthan/6657376 to your computer and use it in GitHub Desktop.
Objetctive c format the numbers with commas
This file contains hidden or 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
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