New issues with Xcode beta: MKGeodesicPolyline

A completely new version of Xcode, in addition to removing a large number of places where you can add an empty function call, is a ridiculous problem with a simple piece of code drawing a geodetic path:

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) } 

The compiler complains about:

Ambiguous use of 'init (coordinates: count :)'

When I try to click on the given parameters, I always come up to this line. I tried to clear the project to no avail.

+4
source share
2 answers

In this case, MKGeodesicPolyline will use either UnsafePointer or UnsafeMutablePointer , using the CLLocationCoordinate2D type that you defined as points, so you most likely want:

 let geodesic = MKGeodesicPolyline(coordinates: points, count: 2) 

Apple Developer: CLLocation

+3
source

Let geodesic = MKGeodesicPolyline (coordinates: & coordinates, number: 2)

  • delete the "&" character in front of the coordinates. This solved the problem.
0
source

Source: https://habr.com/ru/post/1209507/


All Articles