Я пытаюсь передать 1 переменную другому контроллеру представления, а затем другому контроллеру представления.
var selectedPlace = Place {
name = Daniel Webster Highway;
country = United States;
lat = 42.72073329999999;
lon = -71.44301460000001;
}
![enter image description here](https://i.stack.imgur.com/yOX4z.png)
Когда я выбираю ячейку, у меня есть доступ к переменной selectedPlace
Я хочу передать его моему PlaceDetailVC, а также MapVC.
По некоторым причинам я не могу этого сделать.
PlacesVC
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
let destinationVC = segue.destination as! PlaceDetailVC
if let indexPath = tableView.indexPathForSelectedRow {
destinationVC.selectedPlace = (places?[indexPath.row])!
destinationVC.selectedTrip = selectedTrip!
}
}
PlaceDetailVC
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "toMap" {
let destinationVC = segue.destination as! MapVC
if let indexPath = placesTable.indexPathForSelectedRow {
destinationVC.selectedPlace = selectedPlace
}
}
}
я тоже попробую
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
let destinationVC = segue.destination as! MapVC
if let indexPath = placesTable.indexPathForSelectedRow {
destinationVC.selectedPlace = selectedPlace
}
}
MapVC
print(selectedPlace,"<<<<<<")
Результат
Я продолжал получать
![enter image description here](https://i.stack.imgur.com/QFheg.png)
Любые намеки на то, что я сделал не так?