So I have this,
func doStuff() {
//blahblahblah
}
var randomNumber = arc4random() % 4
randomNumber += 1
switch(randomNumber) {
case 1:
doStuff()
break
case 2:
doStuff()
break
case 3:
doStuff()
break
case 4:
doStuff()
break
}
Now I need it to do something like this
func doStuff() {
//blahblahblah
}
var alreadyUsed = [""]
var randomNumber = arc4random() % 4
randomNumber += 1
if randomNumber is not inside alreadyUsed {
switch(randomNumber) {
case 1:
doStuff()
alreadyUsed.append("1")
break
case 2:
doStuff()
alreadyUsed.append("2")
break
case 3:
doStuff()
alreadyUsed.append("3")
break
case 4:
doStuff()
alreadyUsed.append("4")
break
}
}
Essentially, I am trying to have something that will randomly select a case, then won't select the same case again the next time the function is run. I am using that first chunk of code as a function. After a case has been used in that function, I do not want the function to use it again. I hope this makes sense.
Thanks guys!
EDIT: Though I'd find it more useful, It doesn't even have to be an array, as long as it gets the job done.