I am having an issue with Google Maps Reverse Geocoding when it comes to setting a UILabel\'s text to the reverse geocoded address. The UILabel is in an XIB use as a custom info
You are using a return out of the braces of the geocoding, for this reason the last code works. You should do something like this:
func getAddress(currentAdd : ( returnAddress :String)->Void){
let infoWindow = NSBundle.mainBundle().loadNibNamed("InfoWindowCurrent", owner: self, options: nil)[0] as! InfoWindowCurrent
let geocoder = GMSGeocoder()
let coordinate = CLLocationCoordinate2DMake(Double(self.locLatitude)!,Double(self.locLongitude)!)
var currentAddress = String()
geocoder.reverseGeocodeCoordinate(coordinate) { response , error in
if let address = response?.firstResult() {
let lines = address.lines! as [String]
currentAddress = lines.joinWithSeparator("\n")
currentAdd(returnAddress: currentAddress)
}
}
}
And call that function
getAddress() { (returnAddress) in
print("\(returnAddress)")
}