I have a UILabel and its formatter :
NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
[formatter setNumberStyle:NSNumberFormatterDecimalStyle];
[formatter setGroupingSeparator:@"."];
[formatter setGroupingSize:3];
[formatter setAlwaysShowsDecimalSeparator:NO];
[formatter setUsesGroupingSeparator:YES];
[formatter setDecimalSeparator:@","];
NSString *formattedString = [formatter stringFromNumber:[NSNumber numberWithFloat:12.]]];
So that my formattedString is returning 12
What If I want to keep the comma when there is no decimal? So that my UIlabel prints out "12."?
If you want to see comma when there is no decimal, set
alwaysShowsDecimalSeparatoraccordinglyThus, your
UILabelwill say "12," (not "12.").