I have a problem getting the Symbol currency of my NSNumberFormatter.
I am using NSNumberFormatter with the currency code is "EUR".
When I format the prices, the symbol is correct, I get the symbol €.
However, when I want to get only currencySymbol using the [formatter currencySymbol] method, the $ character is returned.
If I manually set currencySymbol (for example, with "A"), everything will work fine, and the [formatter currencySymbol] method will return the character "A".
Here is my code
// Create formatter NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init]; [formatter setNumberStyle:NSNumberFormatterCurrencyStyle]; [formatter setCurrencyCode:@"EUR"]; [formatter setLocale:[NSLocale currentLocale]]; // Log the currency symbol NSLog(@"[formatter currencyCode] : %@", [formatter currencyCode]); NSLog(@"[formatter currencySymbol] : %@", [formatter currencySymbol]); NSLog(@"[formatter currencySymbol] : %@", [formatter stringFromNumber:[NSNumber numberWithInt:0]]); [formatter setCurrencySymbol:@"A"]; NSLog(@"[formatter currencySymbol] : %@", [formatter currencySymbol]); NSLog(@"[formatter currencySymbol] : %@", [formatter stringFromNumber:[NSNumber numberWithInt:0]]);
Here are the console results:
2012-01-17 12:29:11.108[4545:207] [formatter currencySymbol] : $ 2012-01-17 12:29:11.109[4545:207] [formatter currencySymbol] : €0.00 2012-01-17 12:29:11.110[4545:207] [formatter currencySymbol] : A 2012-01-17 12:29:11.111[4545:207] [formatter currencySymbol] : A0.00
I cannot force currencySymbol, as it can change.
Is there a way to get the correct currencySymbol corresponding to this currency code?
thanks
source share