I have tried using the func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) to pass the annotation title to the embedded container view. However when i build and run, it doesn't work.
What am I doing incorrectly? Is this the right approach?
I've tried func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) see code
var annotationTitle = "Default"
func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView){
if let annotation = view.annotation {
annotationTitle = annotation.title!!
}
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "showMapContainer" {
let destination = segue.destination as! MapDetailContainerViewController
destination.selectedAnnotation = annotationTitle as String
}
}
}
The data is being passed to the containerviewcontroller as "Deafult" instead of annotation.title value