I have a class with an annotation as a property
class UserClass {
var id : String?
var annot : MKPointAnnotation?
}
Then I make several instances of this class like:
var user1 = UserClass()
and then define, create and add each user's annotation on the map.
Later in the code user taps on an annotation and I need a reference to the corresponding user instance. How do I get it?
@objc(mapView:didSelectAnnotationView:) func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) {
if let annot = view.annotation as? MKPointAnnotation {
let user = // Need the user instance here to acces user id etc
}
}