Having spent the day converting a project to Swift 2.0, I have am stumped on what is wrong with the following code snippet, which is intended to show an address (supplied in string format) on a map.
geocoder.geocodeAddressString(addressString, completionHandler: {(placemarks: [AnyObject]!, error: NSError!) -> Void in
if(error != nil) {
println("Error", error)
} else if let placemark = placemarks?[0] as? CLPlacemark {
var placemark:CLPlacemark = placemarks[0] as! CLPlacemark
let coordinates:CLLocationCoordinate2D = placemark.location.coordinate
let span:MKCoordinateSpan = MKCoordinateSpanMake(0.01 , 0.01)
let region:MKCoordinateRegion = MKCoordinateRegionMake(coordinates, span)
var pointAnnotation:MKPointAnnotation = MKPointAnnotation()
pointAnnotation.coordinate = coordinates
pointAnnotation.title = locationTitle
pointAnnotation.subtitle = addressString
map.addAnnotation(pointAnnotation)
map.centerCoordinate = coordinates
map.setRegion(region, animated: true)
map.selectAnnotation(pointAnnotation, animated: true)
}
})
This is a lot closer. The function signature has changed,
println
is nowprint
: