Can anyone tell me whats wrong with my code? I have my random number being printed out so that I can see it but even when the number is zero and I'm pressing the left button it still tells me wrong. But it just does it sometimes. Does anyone know what is wrong? I'm writing with swift in Xcode.
var randomNumber = arc4random_uniform(2)
@IBAction func LeftButton(_ sender: Any) {
if randomNumber == 0{
TopLabel.text = "Right!"
}else{
TopLabel.text = "Wrong"
}
}
@IBAction func RightButton(_ sender: Any) {
if randomNumber == 1{
TopLabel.text = "Right!"
}else{
TopLabel.text = "wrong"
}
Aucun commentaire:
Enregistrer un commentaire