I have 2 VC
:
FirstVc
in that i have one textfield NamesTF
.
secondVC
i need to check whether in FirstVc
the NamesTF
have values are not. If values is available my bool
value have to come True
.If values is not available bool
value have to come False
My code :
FirstVc
:
let storyboard = UIStoryboard(name: "DashBoard", bundle: nil)
let destinationVc = storyboard.instantiateViewController(withIdentifier: "SecondVC")
if NamesTF.text == "" {
SecondVC.NameAvailable = false
self.navigationController?.pushViewController(destinationVc, animated: true)
}
else
{
SecondVC.NameAvailable = false
self.navigationController?.pushViewController(destinationVc, animated: true)
}
In my SecondVC
:
var NameAvailable = false
override func viewWillAppear(_ animated: Bool) {
if NameAvailable == true {
// print the name
}
else {
// no name availble //false
}
}
What i am doing wrong. Can any one help me out.
Thanks ~