mercredi 29 juillet 2015

How to use random variable to choose correct button in swift

The title might not be the best explanation of what I want but I couldn't think of a better way to describe it.

@IBOutlet var button0: UIButton!
@IBOutlet var button1: UIButton!
@IBOutlet var button2: UIButton!

var num = (arc4random()%3);

basically I want to use the variable 'num' to choose which button and make it hidden based off the random number. Is there a way to use the variable in a a simple line like "button(num).hidden = true" or something like that?




Aucun commentaire:

Enregistrer un commentaire