I have data from a view controller I want to pass another view controller, but I have it set to present modally, so I have a navigation controller between them. How do I pass data from the first view controller through the navigation controller to the second view controller?
I have this code in the first view controller:
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "presentPopup"
{
let destViewController = segue.destination as! NavigationViewController
destViewController.myData2 = myData
}
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
Then this code in the navigation controller:
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
let destViewController = segue.destination as! SecondViewController
destViewController.myData3 = myData2
}
But it doesn't work.