我如何从货币名称列表中获取语言环境 [英] How can i get the locale from currency names list

查看:102
本文介绍了我如何从货币名称列表中获取语言环境的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建货币选择屏幕.为此,我正在使用以下代码显示货币列表,以创建从中填充表格视图的货币数组

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

推荐答案

您可以在这里使用相同的方法,但只需进行少量修改即可.

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

如何从iPhone中的ISOCountryCode获取ISOCurrencyCode sdk?

NSString * currencyCode = @"ADP";

NSString *currencyCode = @"ADP";

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

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

NSString * localeIdent = [NSLocale localeIdentifierFromComponents:components];

NSString *localeIdent = [NSLocale localeIdentifierFromComponents:components];

这篇关于我如何从货币名称列表中获取语言环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆