开发者

How to test NSLocale return value?

开发者 https://www.devze.com 2023-03-27 10:24 出处:网络
I am using NSLocale to determine my c开发者_Python百科urrent 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.

I am using NSLocale to determine my c开发者_Python百科urrent 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 *locale = [NSLocale currentLocale];
    NSString *countryCode = [locale objectForKey: NSLocaleCountryCode];
    NSString *countryName = [locale displayNameForKey: NSLocaleCountryCode value: countryCode];

Thanks,


From the NSLocale class reference

[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.

0

精彩评论

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