Hi everyone,
I'm pretty new with Swift, and right now i'm using MapKit with a coordinator.
I was pretty satisfied until i had to retrieve where the user touched the map. My aim for the moment is only to draw like a line, a polygon on my map, when the user touches the map.
I followed Paul Hudson's videos (huge thanks to him for the well explained content) to make my MapView and my Coordinator, and another tutorial to draw over my map, which was using a regular controller. I tried to adapt the second to tutorial with my Coordinator.
I finally arrived to the point where i'm trying to override the function "touchesBegan" in my Coordinator like this :
var points = [CLLocationCoordinate2D]() {
didSet {
print(points)
}
}
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
mapViewTest.removeOverlays(mapViewTest.overlays)
if let touch = touches.first {
let coordinate = mapViewTest.convert(touch.location(in: mapViewTest), toCoordinateFrom: mapViewTest)
points.append(coordinate)
}
}
But nothing happens when i use the simulator. Even if i just print something in my "touchesBegan" or "touchesMoved", i don't get anything in my console.
I don't really know what i am doing wrong, and how to do it properly. If you have any tips, i would be thankful.
(Sorry if i made english mistakes !)
Regards,
Samy