Find current country from iPhone device

2019-01-12 20:23发布

I have to get the current country in the iPhone settings. Can anyone tell me how to get the current country in iPhone application.

I have to use the current country for parsing the RSS feed in which I need to pass the current country.

Please help me out to find the country .

Thanks in advance.

9条回答
神经病院院长
2楼-- · 2019-01-12 21:17
NSLocale *locale = [NSLocale currentLocale];
NSString *countryCode = [locale objectForKey: NSLocaleCountryCode];
NSString *country = [locale displayNameForKey: NSLocaleCountryCode value: countryCode];
查看更多
劫难
3楼-- · 2019-01-12 21:18

If you're testing and want to use a different language from your system, it's easiest to change your scheme's Application Language and Application Region options instead of changing the language and region on your device or simulator.

Go to Product->Scheme->Edit Scheme...->Run->Options and choose the Application Language and Application Region you want to test.

Edit Application Language and Application Region within Scheme Run Options

From the iOS Documentation: Testing Your Internationalized App

查看更多
▲ chillily
4楼-- · 2019-01-12 21:21
NSTimeZone *gmt = [NSTimeZone localTimeZone];

NSLog(@"timezone gmt %@",gmt.abbreviation);
查看更多
登录 后发表回答