Search code examples
iosobjective-cnsnumberformatter

How to get the currency symbol


I'm trying to pass the currency symbol to a UILabel. When I try getting the symbol, I get weird results. Here is my code:

self.currencyFormatter = [[NSNumberFormatter alloc] init];
[self.currencyFormatter setLocale:[NSLocale currentLocale]];
[self.currencyFormatter setMaximumFractionDigits:2];
[self.currencyFormatter setMinimumFractionDigits:2];
[self.currencyFormatter setAlwaysShowsDecimalSeparator:YES];
[self.currencyFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];

NSLog(@"%@", self.currencyFormatter.positiveFormat);

The output of the NSLog is: ¤#,##0.00. I'm trying to get $.

How can I get $ (that's for USA)?


Solution

  • The property you seek is named currencySymbol. Or possibly internationalCurrencySymbol.