this is my first question so sorry for mistakes. I found some answers but nothing work in my code. First of all
I made segue and add identifier.
this is in my MainMapViewController:
func mapView(_ mapView: MKMapView, annotationView view: MKAnnotationView, calloutAccessoryControlTapped control: UIControl) {
guard let annotation = mapView.selectedAnnotations.first else {return}
annotationPlace = annotation as? Place
self.performSegue(withIdentifier: "showDetail", sender: self)
}
func showPlaceDetail(segue: UIStoryboardSegue){
let viewController = segue.destination as? PlaceDetailTableViewController
viewController?.selectedPlace = annotationPlace
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "showDetail" {
showPlaceDetail(segue: segue)
}
}
Here is my PlaceDetailTableViewController:
import UIKit
class PlaceDetailTableViewController: UITableViewController {
var selectedPlace:Place?
override func viewDidLoad() {
super.viewDidLoad()
dump(selectedPlace as Any)
print(selectedPlace?.title)
}
}
In my opinion it is something different like normal passing data between VC's because i have to make segue from annotation button