ios – 新的Xcode beta新问题:MKGeodesicPolyline

前端之家收集整理的这篇文章主要介绍了ios – 新的Xcode beta新问题:MKGeodesicPolyline前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
全新的 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)

Apple Developer : CLLocation

猜你在找的Xcode相关文章