全新的
Xcode版本,除了删除大量添加空函数调用的地方外,还通过一段简单的代码描绘了一个有趣的问题,绘制了一个大地测量路径:
func drawPolyline(from startLocation: CLLocation,endLocation:CLLocation) { let point1 = startLocation.coordinate let point2 = endLocation.coordinate var points: [CLLocationCoordinate2D] points = [point1,point2] var coordinates=points[0] let geodesic = MKGeodesicPolyline(coordinates: &coordinates,count:2) self.mapView.add(geodesic) }
编译器抱怨:
Ambiguous use of ‘init(coordinates:count:)’
当我尝试点击给定的选项时,我总是被引导到那一行.我试图清理该项目无济于事.
解决方法
在这种情况下,MKGeodesicPolyline将使用您定义为点的CLLocationCoordinate2D类型使用UnsafePointer或UnsafeMutablePointer,因此您可能需要:
let geodesic = MKGeodesicPolyline(coordinates: points,count: 2)