阅读背景:

将值传递给闭包函数

来源:互联网 

Check out this code:

看看这段代码:

func getReversedGeocodeLocation(location: CLLocation, completionHandler: @escaping ()->()) {
    CLGeocoder().reverseGeocodeLocation(location, completionHandler: {(placemarks, error) -> Void in

        if error != nil {
            print("Reverse geocoder failed with error" + error!.localizedDescription)
            return
        }

        if placemarks != nil {
            if placemarks!.count > 0 {
                let pm = placemarks![0]
                if let addressDictionary: [AnyHashable: Any] = pm.addressDictionary,
                let addressDictionaryFormatted = addressDictionary["FormattedAddressLines"] {
                    let address = (addressDictionaryFormatted as AnyObject).componentsJoined(by: ", ")
                    self.addressInViewController = address
                }
                completionHandler()
            }
        } else {
            print("Problem with the data received from geocoder")
        }
    })
}
func getRevers



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: