I need to access the value of a variable in a if statement, this is my code:
var codeError : Int?
@IBAction func mySwitch(_ sender: UISwitch) {
if sender.isOn {
codeError = 1
} else {
codeError = 2
}
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
print(codeError!)
}
But, I need to print(codeError!)
print 1 or 2.
How do I achieve this? đ€
Aucun commentaire:
Enregistrer un commentaire