Re: How to retrieve currencies list
Re: How to retrieve currencies list
- Subject: Re: How to retrieve currencies list
- From: Chris Kane <email@hidden>
- Date: Thu, 27 Apr 2006 16:27:40 -0700
On Apr 27, 2006, at 7:21 AM, Thilo Ettelt wrote:
You can retrieve the currency code and symbol using
NSNumberFormatter and NSLocale (see documentation). But I couldn't
find a method to retrieve the currency name. But I need that one too.
- Thilo
Am 27.04.2006 um 09:37 schrieb Eric Morand:
Hi list !
I'd like to retrieve the currencies list available in the
International preference pane. Is it possible ?
This is what the "display name" method is for. In this case, you ask
the locale into which you want the name localized for the display name
of the particular currency code.
#import <Foundation/Foundation.h>
int main() {
NSLocale *locale;
NSString *dollars, *yen;
[NSAutoreleasePool new];
locale = [NSLocale currentLocale];
dollars = [locale displayNameForKey:NSLocaleCurrencyCode
value:@"USD"];
yen = [locale displayNameForKey:NSLocaleCurrencyCode value:@"JPY"];
NSLog(@"%@: '%@', '%@'", [locale localeIdentifier], dollars, yen);
locale = [[[NSLocale alloc] initWithLocaleIdentifier:@"de"]
autorelease];
dollars = [locale displayNameForKey:NSLocaleCurrencyCode
value:@"USD"];
yen = [locale displayNameForKey:NSLocaleCurrencyCode value:@"JPY"];
NSLog(@"%@: '%@', '%@'", [locale localeIdentifier], dollars, yen);
locale = [[[NSLocale alloc] initWithLocaleIdentifier:@"fr"]
autorelease];
dollars = [locale displayNameForKey:NSLocaleCurrencyCode
value:@"USD"];
yen = [locale displayNameForKey:NSLocaleCurrencyCode value:@"JPY"];
NSLog(@"%@: '%@', '%@'", [locale localeIdentifier], dollars, yen);
return 0;
}
2006-04-27 16:24:52.511 a.out[3373] en_US: 'US Dollar', 'Japanese Yen'
2006-04-27 16:24:52.516 a.out[3373] de: 'US Dollar', 'Yen'
2006-04-27 16:24:52.516 a.out[3373] fr: 'dollar des États-Unis', 'yen'
Note that the system does not necessarily have localized names for all
combinations of languages and currencies.
Chris Kane
Cocoa Frameworks, Apple
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden