Generate a random number

 Problem

I want to generate a random number, between 0 and N-1.



 Recipe


// Generate a random number
// between 0 and 9 (10-1)

let rand = Int(arc4random_uniform(10))

print(rand)
				

Heard the news?

The Swift Cookbook for Swift 3 is at last here! For iBooks, Kindle and Paperback.
Hurry up - and Check it out! ;-)

 

 Playground