我试图生成两个整数之间的随机值.我试过这个,从0开始,
let randomNumber = arc4random_uniform(10) println(randomNumber)
但是我需要10到50之间的值.
尝试这个
原文链接:https://www.f2er.com/swift/318777.htmllet randomNumber = arc4random_uniform(40) + 10 println(randomNumber)
一般形式
let lower : UInt32 = 10 let upper : UInt32 = 50 let randomNumber = arc4random_uniform(upper - lower) + lower println(randomNumber)