Hi I am trying to use geocodeAddressString to convert the address to a placemark on the map, but whatever address I passed to this method, the below block will never be executed, could anyone give me some light? Thanks a lot By the way, I can see "before" and "after" on the concole, but without "hello"
let geo = CLGeocoder()
print("before")
geo.geocodeAddressString(("4 Bradford St, Perth WA 6050"), completionHandler: {
(placemarks, error) -> Void in
print ("hello")
if let placemark = placemarks?[0]
{
self.mapView.addAnnotation(MKPlacemark(placemark: placemark))
}
})
print ("after")
geocodeAddressString
line? – Delawaregeo
fell out of scope, but it looks likegeocodeAddressString
keeps the geocoder alive until the request finishes. And even if you had somecancelGeocode()
calls lingering elsewhere in your code, you'd at least see "hello" message. – Delaware