I am using CoreLocation to get a user’s latitude and longitude coordinates. Is there a simple or standardized way to get the user’s state prefix? For example, if the user launched the app from California, I would get CA? I would prefer not to use a third party application that I need to send the geo-coordinates to. It would be great if I could just create a method like the one I am using to get the latitude below.
- (NSString *)getUserLatitude
{
NSString *userLatitude = [NSString stringWithFormat:@"%f",
locationManager.location.coordinate.latitude];
return userLatitude;
}
Please let me know if you have any ideas. Thank you!
You have to use the reverse geocoding feature of CLGeocoder.
Specifically you need to use the method
reverseGeocodeLocation:completionHandler:that will return to your completionHandler aCLPlacemarkobject.Such object will have many user-friendly geographical information and you may want to use its
administrativeAreaproperty which, according to the doc, will contain what you’re looking for, if available.