Note that there are some explanatory texts on larger screens.

plurals
  1. POError with NSNumberFormatter currencySymbol
    primarykey
    data
    text
    <p>I have a problem getting the currencySymbol of my NSNumberFormatter.<br/> I use a NSNumberFormatter with a currency code "EUR".<br/> When I format prices, the symbol is correct, I get the € symbol.<br/> However, when I want to get just the currencySymbol with the method [formatter currencySymbol], the symbol $ is returned.<br/> If I manually set the currencySymbol (with "A" for instance) everything will work fine and the method [formatter currencySymbol] will return the "A" symbol.<br/> <br/> <br/> Here is my code</p> <pre><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]]); </code></pre> <p>Here are the console results :</p> <pre><code>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 </code></pre> <p>I cannot force the currencySymbol since it can change.<br/> Is there a way to get the right currencySymbol corresponding to a given currencyCode ?</p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload