How can i get the locale from currency names list

限于喜欢 提交于 2019-12-24 04:31:41

问题


i am making a currency selecting screen.for that i am displaying the list of currencies using the following code to create an array of currencies from which a tableview is populated

NSArray *countryArray = [NSLocale ISOCurrencyCodes];
    for(NSString *country in countryArray)
    {
        //NSLog(@"%@",[[NSLocale currentLocale] displayNameForKey:NSLocaleCurrencyCode value:country]);
        if([[NSLocale currentLocale] displayNameForKey:NSLocaleCurrencyCode value:country])
        {
        [countriesArray addObject:[[NSLocale currentLocale] displayNameForKey:NSLocaleCurrencyCode value:country]];
        }
    }

.but i cant find a way to connect a currencies name and locale.ie if i select a currency name then i should be able to set the corresponding locale for currency display in other screens.How to find the locale from currencies list


回答1:


You can use the same method from here with small modification..

How to get ISOCurrencyCode from a ISOCountryCode in iphone sdk?

NSString *currencyCode = @"ADP";

NSDictionary *components = [NSDictionary dictionaryWithObject:currencyCode forKey:NSLocaleCurrencyCode];

NSString *localeIdent = [NSLocale localeIdentifierFromComponents:components];



来源:https://stackoverflow.com/questions/7477702/how-can-i-get-the-locale-from-currency-names-list

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!