John Smith John Smith - 1 year ago 125
Swift Question

random is unavailable in Swift: Use arc4random

Still very very new to swift and I got this error. I was opening some sample code and this is what the result was after I converted to swift 3. I am using Xcode 8.

var imageURL: URL
var detailURL: URL
var imageURLString: String
var detailURLString: String
var color: String
let sessionID: Int=random()%50000 - this is the error

Answer Source

Use the arc4random method:

let sessionID = Int(arc4random_uniform(50000))
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download