Maybe this is a silly answer but I'm pretty new on ios.. I have to show a number in an specific way in my app. Currently, I have numbers that I receive from a service in an NSString. But, e.g. if I have a number: 123456789, i need to show it in a label as 123.456.789 .. anyone knows if there is some way to do that?
Edit: add ios and iphone tags
Use NSNumberFormatter:
NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
[formatter setNumberStyle:NSNumberFormatterDecimalStyle];
NSString *formattedOutput = [formatter stringFromNumber:[attributesDict objectForKey:NSFileSystemFreeSize]];
NSLog(@"System free space: %@", formattedOutput);
If your number comes in as a string first, you'll need to make a number out of it first which you can do using NSString's intValue method:
http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html#//apple_ref/occ/instm/NSString/intValue
[NSString localizedStringWithFormat:@"%@", myNumber];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With