Hey I have some coordinates ["37.7", "-122.4"] that I am trying to use to reverse geoCode. So I can get the city and state for a simple UI Label. However when I use CLLocation to get the state via the administrativeArea var/method that comes standard with a placeMark it returns nil.
▿ some : 1 element - 0 : San Francisco Bay, San Francisco Bay, San Francisco, United States @ <+37.80000000,-122.50000000> +/- 100.00m, region CLCircularRegion (identifier:'<+37.79999999,-122.50000000> radius 141.72', center:<+37.79999999,-122.50000000>, radius:141.72m)
This is what I get back from the completion handler. Which makes it obvious that there is no state that is getting returned from this. Why would that be and how can I still get the state.
Enclosed is the block of code that controls this acton all help is appreciated.
CLGeocoder().reverseGeocodeLocation(location, completionHandler: { (placeMark, error) in
if error != nil{
print("There was an error")
}else{
if let place = placeMark?[0]{
print(place)
print(place.locality ?? "")
print(place.subAdministrativeArea ?? "")
let myAttribute = [NSAttributedStringKey.font:UIFont(name: "Times New Roman", size: 15.3)!]
let myAttrString = NSAttributedString(string: place.locality ?? "", attributes: myAttribute)
locLabel.attributedText = myAttrString
}
}
})