Sunday, September 28, 2014

Swift - Generating a random number

If you want to generate a random number in Swift, use the arc4random_uniform() function. The following code snippet generates a number from 0 to 9:

var i = Int(arc4random_uniform(10))

No comments: