私は更新したいアドレスのリストを持っています。アドレスのリストを配列に読み込んだら、CLGeocoderのgeocodeAddressString関数を呼び出します。CLGeocoderの完了ハンドラからリスト内のアドレスを更新する方法geocodeAddressString()
補完ハンドラでは、アドレスリスト内のどのインデックスがgeocodeAddressString呼び出しの作成に使用されたかをどのように知っていますか?
基本的に私はどのように私は、この例= 1で、私はインデックスを知っていますかどのようにも場所アレイに戻って取得してください
locations[1].MailAddr1 = placemark.name
locations[1].MailCity = placemark.locality
locations[1].MailState = placemark.administrativeArea
locations[1].MailZip = placemark.postalCode
locations[1].lat = placemark.location!.coordinate.latitude
locations[1].long = placemark.location!.coordinate.longitude
を設定したいと思いますか?
私は配列全体をループすることができればと考えています。
私はあなたの場所がクラスであると仮定しlet locations = ReadCSV()
let address = locations[1].MailAddr1 + ", " + locations[1].MailCity + ", " + locations[1].MailState + ", " + locations[1].MailZip + ", " + locations[1].MailCountry
let geocoder = CLGeocoder()
geocoder.geocodeAddressString(address, completionHandler: {(placemarks, error) -> Void in
if((error) != nil){
print("Error", error)
}
if let placemark: CLPlacemark = placemarks?.first {
let name = placemark.name
let address = placemark.thoroughfare
let locality = placemark.locality
let zip = placemark.postalCode
let subLocality = placemark.subLocality
let country = placemark.country
let coordinates:CLLocationCoordinate2D = placemark.location!.coordinate
let location: CLLocation = placemark.location!
}
})