Volkodav
Volkodav

Reputation: 600

Int is not convertible to UIint32 error

i am new to swift and Xcode and i need some help. I have a function that gets to integer variables. And when i use them they give me errors. here is the code

func checkTheNumber(range: Int, numberOfGuesses: Int) { var randomNumber = Int(arc4random_uniform(range) + 1) numberOfGuesses-- when i try to use the range variable it says "Int is not convertible to UIint32" and when i try to use number of guesses it says "unary operator cannot be applied to an operand of type Int"

Upvotes: 1

Views: 174

Answers (1)

Ashish Kakkad
Ashish Kakkad

Reputation: 23882

Change it with :

 var randomNumber = Int(arc4random_uniform(UInt32(range)) + 1)

You have to cast the Int to UIint32

Upvotes: 1

Related Questions