My application is allowing user to select various currencies for spendings tracking.
I have a label which displays the amount with currecy symbol. I'm using NSNumberFormatter
with kCFNumberFormatterCurrencyStyle
to format the amount string and display it in the label;
numberFormatter = [[NSNumberFormatter alloc] init];
numberFormatter.numberStyle = kCFNumberFormatterCurrencyStyle;
numberFormatter.currencyCode = @"EUR";
My goal is to display the currency symbol with different color, so i'm using NSAttributedString, trying to find symbols' range and set different attributes to it. The problem is that the formatter return wrong symbol when I initilizing the attributed string:
MLOG(@"internationalCurrencySymbol %@", numberFormatter.internationalCurrencySymbol);
MLOG(@"currencySymbol %@", numberFormatter.currencySymbol);
MLOG(@"currencyCode %@", numberFormatter.currencyCode);
//logs:
//USD
//$
//EUR
but when the label is displayed on the screen I see correct Euro currency symbol: €
Does anybody know how can get the currency symbol for given currency code?