This question already has an answer here:
- How to generate random numbers without repetition in Swift? [duplicate] 1 answer
In my application, I use something like this to get random text on my label, except in my main let randomNumber
code, in xCode, it has over 300 cases, to much to paste in here.:
let randomNumber = Int(arc4random_uniform(23))
var textLabel = "" as NSString
switch (randomNumber){
case 1:
textLabel = "Kim."
break
case 2:
textLabel = "Phil."
break
case 3:
textLabel = "Tom"
break
case 4:
textLabel = "Jeff"
break
default:
textLabel = "Austin"
}
self.randomLabel.text = textLabel as String
But the problem is, that sometimes it shows the same text on the label 5-6 times, and other cases is not even used yet, because it choose randomly. So how can I choose randomly, but if case example case 1 is already shown, it wont show up again, until all other cases has been shown.