Eric
Eric

Reputation: 4061

Use CurrentLocation for Continent iPhone

Is there a way to find out the users location Continent? I need to set an AWS entry point based on if they open the app in the US, or Europe. etc.

Is there a way to do this without taking GPS coordinates and making ranges out of them?

Upvotes: 1

Views: 459

Answers (3)

iOSCowboy
iOSCowboy

Reputation: 1426

Although a CLPlacemark object contains lots of useful information, its corresponding continent is not present on it.

I wrote a small category to add a -continent method that returns the corresponding string of the continent based on the -ISOCountryCode of a CLPlacemark.

https://github.com/Hecktorzr/Transcontinental

Upvotes: 0

Antonio MG
Antonio MG

Reputation: 20410

If you are in iOS5, you can use GLGeocoder to retrieve the information abotu a current location:

[self.CLGeocoder reverseGeocodeLocation: locationManager.location completionHandler: 
 ^(NSArray *placemarks, NSError *error) {

     CLPlacemark *placemark = [placemarks objectAtIndex:0];

         //placemark contains the address

}];

CLPlacemark reference:

https://developer.apple.com/library/ios/#DOCUMENTATION/CoreLocation/Reference/CLPlacemark_class/Reference/Reference.html

GLGeocoder reference:

https://developer.apple.com/library/ios/#DOCUMENTATION/CoreLocation/Reference/CLGeocoder_class/Reference/Reference.html

Upvotes: 2

wattson12
wattson12

Reputation: 11174

you can reverse geocode a location and get details of where the user is located in text. You use the reverseGeocodeLocation:completionHandler: method on the CLGeocoder class to do this

The completion handler in this method gets passed in an array of CLPlacemark objects, which contain the country code, which you can use to determine the users continent

Upvotes: 2

Related Questions