Is is possible to derive currency symbol from currency code?

Posted by Dave Hunt on Stack Overflow See other posts from Stack Overflow or by Dave Hunt
Published on 2010-04-04T10:52:12Z Indexed on 2010/04/04 10:53 UTC
Read the original article Hit count: 392

Filed under:
|
|

My iPhone app formats an NSDecimalNumber as a currency using setCurrencyCode, however another screen displays just the currency symbol. Rather than storing both the currency code and symbol, is it possible to derive the symbol from the code? I thought the following might work, but it just returns the symbol as $:

currencyCode = [dictPrices valueForKey:@"currencyCode"];
NSNumberFormatter *numberFormatter = [[[NSNumberFormatter alloc] init] autorelease];
[numberFormatter setFormatterBehavior:NSNumberFormatterBehavior10_4];
[numberFormatter setCurrencyCode:currencyCode];
[numberFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];

NSString *currencySymbol = [numberFormatter currencySymbol];

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c