jim*_*jon 4 geocode ios swift2
这曾经在Swift 1.2中运行良好但现在给出错误:
"无法使用类型'的参数列表调用'geocodeAddressString'(String,completionHandler:([AnyObject]!,NSError!) - > Void)'"
geocoder.geocodeAddressString(address, completionHandler: {(placemarks: [AnyObject]!, error: NSError!) -> Void in
if let placemark = placemarks?[0] as? CLPlacemark {
let annotation = MKPointAnnotation()
Run Code Online (Sandbox Code Playgroud)
编辑答案:
geocoder.geocodeAddressString(address, completionHandler: {(placemarks: [CLPlacemark]?, error: NSError?) -> Void in
Run Code Online (Sandbox Code Playgroud)
完成处理程序中的变量未正确设置,您不包含声明只是 -
coder.geocodeAddressString("1 infinite loop, cupertino, ca") { (placemarks, error) -> Void in
if let firstPlacemark = placemarks?[0] {
print(firstPlacemark)
}
}
Run Code Online (Sandbox Code Playgroud)
请注意,类型推断不需要的可选强制转换将是CLPlacemark
| 归档时间: |
|
| 查看次数: |
3222 次 |
| 最近记录: |