0

プロジェクトを Swift 2.0 に変換するのに 1 日を費やしたので、次のコード スニペットの問題点に困惑しました。このコード スニペットは、地図上に住所 (文字列形式で提供) を表示することを目的としています。

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)
    }
})
4

1 に答える 1