I want to format the number in the currency string. These are the following cases:
25.00 => $25 25.43 => $25.43 25.4 => $25.40 0.00 -> $0
Is there a way to do this in NSNumberFormatter ?
This is my code right now:
NSNumberFormatter *fmt = [[NSNumberFormatter alloc] init]; [fmt setNumberStyle:NSNumberFormatterCurrencyStyle]; [fmt setCurrencyCode:@"USD"];
However, this fails for my first and last examples.
I also tried:
NSNumberFormatter *fmt = [[NSNumberFormatter alloc] init]; [fmt setPositiveFormat:@"$0.##"];
However, this is not suitable for my third case. Any suggestions?
source share