Hello,
I have gotten stumped on this one, I am working with segue's and received the message below while trying to use the "==" operator for the if else. The error message is
Binary operator '==' cannot be applied to operands of type 'UIButton' and '(Any) -> ()'
I have also included the code written so far on this. I understand it does not like the operator to be used to compare the UIButton but not clear on how to fix it. Thank You
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var Username: UITextField!
@IBAction func forgotUsername(_ sender: Any) {
performSegue(withIdentifier:"forgotUsername" , sender:forgotUsername)
}
@IBAction func forgotPassword(_ sender: Any) {
performSegue(withIdentifier: "forgotPassword", sender: forgotPassword)
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
guard
let sender = sender as? UIButton else {
return
}
if sender == forgotUsername {
segue.destination.navigationItem.title = "ForgotUsernameButton"
} else if sender == forgotPassword {
segue.destination.navigationItem.title = "ForgotPasswordButton"
} else {
segue.destination.navigationItem.title = Username.text
}
}
}