Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find current country from iPhone device

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.

like image 663
AppAspect Avatar asked Oct 15 '10 08:10

AppAspect


People also ask

How can I track my Apple phone?

You can use Find My iPhone on iCloud.com to find the approximate location of your iPhone, iPad, iPod touch, Mac, Apple Watch, AirPods and Beats product if Find My is set up and the device is online. To sign in to Find My iPhone, go to icloud.com/find.

What is Cllocationmanager in Swift?

The object that you use to start and stop the delivery of location-related events to your app.

What is locale in Swift?

Information about linguistic, cultural, and technological conventions for use in formatting data for presentation.


1 Answers

To find the country of the user's chosen language:

NSLocale *currentLocale = [NSLocale currentLocale];  // get the current locale. NSString *countryCode = [currentLocale objectForKey:NSLocaleCountryCode]; // get country code, e.g. ES (Spain), FR (France), etc. 

In Swift:

let currentLocale = NSLocale.currentLocale() let countryCode = currentLocale.objectForKey(NSLocaleCountryCode) as? String 

If you want to find the country code of the current timezone, see @chings228's answer.

If you want to find the country code of the device's physical location, you will need CoreLocation with reverse geocoding. See this question for detail: How can I get current location from user in iOS

like image 60
kennytm Avatar answered Sep 25 '22 06:09

kennytm