arc4random()這個全局函數會生成9位數的隨機整數
1,下面是使用arc4random函數求一個1~100的隨機數(包括1和100)
let temp:Int = Int(arc4random()%100)+1 print(temp)
2,下面是使用arc4random_uniform函數求一個1~100的隨機數(包括1和100)
let temps:Int = Int(arc4random_uniform(100))+1 print(temps)
arc4random_uniform會隨機返回一個0到上界之間(不含上界)的整數。以2為上界會得到0或1,像投硬幣一樣
