Learn Courses My Dashboard

Xcode doesent recognize random()

Hey, so I’m using Xcode 8.2.1 and for some reason it just doesn’t recognise the keyword: random. So every time I type Int.random() it shows me an error. Do you have an idea what I can use instead??

Xcode 8.2.1 ???

Man that version if a dinosaur.

You could try:

let randomNumber = arc4random_uniform(13)

which will generate a random number between 0 and 13. If you want a number between 1 and 14 then do this:

let randomNumber = arc4random_uniform(13) + 1