Can I get the code for the local currency from an NSLocale? I tried this:
NSLocale *locale = [[[NSLocale alloc] initWithLocaleIdentifier:@"fr_FR"] autorelease];
NSString *currencyCode = [locale objectForKey:NSLocaleCurrencyCode];
but currencyCode comes back as nil (I wanted "EUR", or similar).
Your code works perfectly fine for me in a regular Macintosh app.
NSLocale *locale = [[[NSLocale alloc] initWithLocaleIdentifier:@"fr_FR"] autorelease];
NSString *currencyCode = [locale objectForKey:NSLocaleCurrencyCode];
NSLog( @"currencyCode is %@", currencyCode );
displays this in the console:
2011-11-14 14:53:33.784 Testing[26388:707] currencyCode is EUR
Are you trying to build this as a command line (Foundation) app or something non-traditional-Mac-like?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With