I have a function that chooses a random button and sets its character to a certain emoji. I want to now set the remaining UIButtons to be random emojis.
How would I determine which UIButtons were not set from the random generator assigning one a value?
Also I want to make sure that the value being assigned is not the same as the value that was inserted at the random generator.
@IBOutlet weak var topLeftAnswer: UIButton!
@IBOutlet weak var topRightAnswer: UIButton!
@IBOutlet weak var bottomLeftAnswer: UIButton!
@IBOutlet weak var bottomRightAnswer: UIButton!
func correctAnswerGen() {
var correct: UInt32 = arc4random_uniform(4)
switch correct{
case 0: topLeftAnswer.setTitle("đ", forState: UIControlState.Normal)
case 1: topRightAnswer.setTitle("đ", forState: UIControlState.Normal)
case 2: bottomLeftAnswer.setTitle("đ", forState: UIControlState.Normal)
case 3: bottomRightAnswer.setTitle("đ", forState: UIControlState.Normal)
default: break
}
//assign other 3 buttons to another emoji value.
}
Aucun commentaire:
Enregistrer un commentaire