本文介绍了如何从iphone sdk中的ISOCountryCode获取ISOCurrencyCode?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有ISOCountryCode可用,现在我想从ISOCountryCode派生这个国家的currencyCode。我该如何实现?
I have the ISOCountryCode avaliable and now i want to derive the currencyCode of this country from the ISOCountryCode. How can i achieve that?
NSString *countryCode = < get from someother view>;
NSString *currencyCode = ?;
我从运行时的其他视图收到此国家/地区代码?
I receive this country code from some other view on runtime?
推荐答案
您需要使用NSLocale。要从特定国家/地区代码中检索货币代码:
You will need to use NSLocale. To retrieve the currency code from a specific country code:
NSString *countryCode = @"US";
NSDictionary *components = [NSDictionary dictionaryWithObject:countryCode forKey:NSLocaleCountryCode];
NSString *localeIdent = [NSLocale localeIdentifierFromComponents:components];
NSLocale *locale = [[[NSLocale alloc] initWithLocaleIdentifier:localeIdent] autorelease];
NSString *currencyCode = [locale objectForKey: NSLocaleCurrencyCode];
您还可以获取当前区域设置,即用户设置:
You can also get it for the current locale, ie the user settings:
NSString *currencyCode = [[NSLocale currentLocale] objectForKey: NSLocaleCurrencyCode];
这篇关于如何从iphone sdk中的ISOCountryCode获取ISOCurrencyCode?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!