Cannot convert value of type '[Dictionary]' to expected argument type 'UnsafePointer'
Is the error I'm getting when trying to insert coordinates into my array.
Here is my code:
var locations: [CLLocationCoordinate2D] = []
//Updating location + polylines
@objc func update()
{
Annotationtimer = Timer.scheduledTimer(withTimeInterval: 10, repeats: true, block: { (timerr) in
let currentLat = self.locationManager.location?.coordinate.latitude
let currentLong = self.locationManager.location?.coordinate.longitude
let location = [(currentLat!), (currentLong!)]
self.locations.append(location) //HERE IS THE ERROR
print(self.locations)
//Draw polyline on the map
let aPolyLine = MKPolyline(coordinates: locations, count: locations.count)
//Adding polyline to mapview
self.mapView.addOverlay(aPolyLine)
})
}
I'm trying to insert current location into an array, and when I press a button, I wanna draw polylines from start, through all coordinates.
What am I doing wrong? How can I insert the coordinates correctly? I've read other threads about this, but none of them is actually working. So I'd to create a new one.
Why dislike? At least you can tell me the reason for it.