vendredi 14 juillet 2017

SWIFT, Put picked randoms last in queue?

I'm relatively new to swift and now I'm simply playing around and learning. I have an array of strings and I'm using arc4random_uniform to print these lines of text. But I can't seem to figure out how to exclude the already picked ones from being picked repeatedly. At least until all the rest have been picked. What I've got:

let array1 = ["pizza", "carrot", "fish", "monkey", "window"]

let pickOfArray = Int(arc4random_uniform(4))

print array1[pickOfArray]




Aucun commentaire:

Enregistrer un commentaire