Generate random integers

Today, I would like to show you how to generate random integers.

import UIKit

func Generaterandomnumbers(){
let randomnumber = Int(arc4random_uniform(4)) //arc4random_uniform could return 0, 1, 2 or 3 but not 4.
print(randomnumber) //Print the random number
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s