开发者

How can i get the locale from currency names list

开发者 https://www.devze.com 2023-04-05 19:24 出处:网络
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

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

开发者_如何学Go
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


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];

0

精彩评论

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

关注公众号