I am using NSLocale to determine my current country and then pass it as an argument to my web service but i can't test other countries such as Africa etc. through this. Is there a way to test this? I am doing this to get the country name:
我正在使用NSLocale来确定我当前的国家,然后将它作为一个参数传递给我的web服务但是我不能通过这个测试其他国家,比如非洲等等。有办法测试这个吗?我这么做是为了得到国家的名字:
NSLocale *locale = [NSLocale currentLocale];
NSString *countryCode = [locale objectForKey: NSLocaleCountryCode];
NSString *countryName = [locale displayNameForKey: NSLocaleCountryCode value: countryCode];
Thanks,
谢谢,
1 个解决方案
#1
2
From the NSLocale class reference
来自NSLocale类引用
[NSLocale availableLocaleIdentifiers] returns an NSArray of strings of locales the device understands. Each of these can be passed to [[NSLocale alloc] initWithLocaleIdentifier:aString] to give you a locale to test with.
[NSLocale ablelocaleidentifier]返回设备所理解的字符串的NSArray。每一个都可以传递到[[NSLocale alloc] initWithLocaleIdentifier:aString]来给您一个测试的locale。
#1
2
From the NSLocale class reference
来自NSLocale类引用
[NSLocale availableLocaleIdentifiers] returns an NSArray of strings of locales the device understands. Each of these can be passed to [[NSLocale alloc] initWithLocaleIdentifier:aString] to give you a locale to test with.
[NSLocale ablelocaleidentifier]返回设备所理解的字符串的NSArray。每一个都可以传递到[[NSLocale alloc] initWithLocaleIdentifier:aString]来给您一个测试的locale。