I want to pass data from a view controller to another but I've a Navigation controller between them, so there's a "present" function instead a "performSegue".
private func IniciarMainAdmin(){
let mainAdmin = UIStoryboard(name: "Main", bundle: Bundle.main)
guard let mainAdminNVC = mainAdmin.instantiateViewController(withIdentifier: "NCMainAdmin") as? NCMainAdmin else{
return
}
present(mainAdminNVC, animated: true, completion: nil)
}
I've tried with this code but it didn't work for me:
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
let destViewController = segue.destination as! NCMainAdmin
let secondViewcontroller = destViewController.viewControllers.first as! NCMenuAdmin
secondViewcontroller.adminUserData = "This is a test"
}
Notes:
- NCMainAdmin is the Navigation Controller
- NCMenuAdmin is the first View Controller of the Navigation Controller
Thanks!