开发者

how to set the locale according to the currency code selected

开发者 https://www.devze.com 2023-04-09 09:42 出处:网络
is there a way to set the locale according to the currency code selected .i can get a list of currency codes.now if i select a currency code say USD ,then i should be able to get the locale identifier

is there a way to set the locale according to the currency code selected .i can get a list of currency codes.now if i select a currency code say USD ,then i should be able to get the locale identifier "en-US" and set the locale accordingly.The purpose is to format all currencies used in my application to this locale. how to do this?

i now set the normal string to currency string using the code

NSLocale* locale = [[[NSLocale alloc] initWithLocaleIdentifier:@"ja_JP"] autorelease]; 
NSDecimalNumber *someAmount = [NSDecimalNumber decimalNumberWithString:unformattedString];
NSNumberFormatter *currencyFormatter = [[NSNumberFormatter alloc] init]开发者_运维问答; 
[currencyFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
[currencyFormatter setLocale:locale];

for that i have to get the locale identifier(in this case @"ja_JP"). in my app i have an option to change the currency.if euro is set then the locale identifier changes

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号