0

I want that my two random generated labels does not generate the same number like 5 and 5

I have done everything else but this

else if rightScoreLabel == leftScoreLabel {
// what goes here?
{

sorry i’m starter

jeeah
  • 23
  • 1

1 Answers1

3

Try approaching this another way: keep generating new numbers until you have two different values.

var a = 0
var b = 0
while a == b {
    a = Int(arc4random_uniform(10))
    b = Int(arc4random_uniform(10))
}

Alternatively, you can regenerate just one of the numbers:

var a = Int(arc4random_uniform(10))
var b = 0
repeat {
    b = Int(arc4random_uniform(10))
} while a == b
Russell
  • 5,436
  • 2
  • 19
  • 27
Sweeper
  • 213,210
  • 22
  • 193
  • 313