0

這是我正在使用的代碼。我不確定應該將哪些變量傳遞給完成處理程序。我查看的每一篇文章都說通過「地標」和「錯誤」,但我遇到了警告和錯誤。CLGeocoder()。reverseGeocodeLocation;處理程序應該是什麼?

func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { 
    CLGeocoder().reverseGeocodeLocation(manager.location!, completionHandler:{ ([placemark: CLPlacemark?], error: NSError?) in 
     print(error) 
    }) 
} 

回答

0

下面是完整的功能:

func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]){ 

    CLGeocoder().reverseGeocodeLocation(manager.location!, completionHandler: {(placemarks, error)-> Void in 

     currentLatitude = String(manager.location!.coordinate.latitude) 
     currentLongitude = String(manager.location!.coordinate.longitude) 

    }) 
} 

希望這有助於!

+0

謝謝!這擺脫了錯誤。 – KodInc

相關問題