I'm trying to display a price in cents (99¢
) instead of dollars ($0.99
) using NSNumberFormatter and a locale.
This code turns a price of 99 cents into the string: $0.99
. Is there a way to get NSNumberFormatter to try to use smaller/cent denominations, when possible, instead?
NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
[numberFormatter setFormatterBehavior:NSNumberFormatterBehavior10_4];
[numberFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
[numberFormatter setLocale:product.priceLocale];
NSString *formattedPriceString = [numberFormatter stringFromNumber:product.price];