Good evening lovely community,
this is my first post, please have mercy, if I do something wrong.
I know there are some similar questions here, but I doesn't understand it.
Maybe I understand, if someone explain it on my code.
// these are my two TextFields and the "finish"-Button.
@IBOutlet weak var goalPlayerOne: UITextField!
@IBOutlet weak var goalPlayerTwo: UITextField!
@IBOutlet weak var finishedGameButton: UIButton!
// here are my function, it should tell me, which Player has won like A < B, so B has won.
@IBAction func finishedGameButtonPressed(_ sender: Any) {
// define UITextField as Integer
let goalPlayerOne = "";
let goalOne = Int(goalPlayerOne);
let goalPlayerTwo = "";
let goalTwo = Int(goalPlayerTwo);
// here is the problem:
"Binary operator '<' cannot be applied to two 'Int?' operands"
// if I make a '==' it works
if goalOne < goalTwo{
displayMyAlertMessage(userMessage: "Player Two wins")
return
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…