max_
max_

Reputation: 24481

Get User's Country

I just wanted to know how I could find out the current user's country using Xcode (iPhone Dev SDK).

Upvotes: 3

Views: 6531

Answers (1)

user470763
user470763

Reputation:

If you want to get the users country you can do two things. The easiest is to deciper it from their localization settings.

NSLocale *locale = [NSLocale currentLocale];
NSString *country = [locale displayNameForKey:NSLocaleIdentifier value:[locale localeIdentifier]];

This can be unreliable (e.g. a user who is abroad). If you depend on the information you should use CoreLocation to find the users current location and then use reverse geo-tagging to get the country from the co-ordinates. Take a look at the CoreLocation Framework reference. It should help you.

Upvotes: 13

Related Questions