0

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 
John Smith
  • 33
  • 2
  • 4
    And your question is? The solution to your problem is in your subject line, so what are you asking? – pjs Oct 25 '16 at 18:03
  • 1
    Related: [What is the equivalent of seeded random in Swift3](http://stackoverflow.com/questions/37872765/what-is-the-equivalent-of-seeded-random-in-swift3-xcode8-beta-1). – Martin R Oct 25 '16 at 18:07
  • In your early steps, ALWAYS try to understand the error. Compile time errors are very easy to read and understand. They help you to understand how the compiler thinks. Runtime errors are a bit harder to understand. Likely it would be coupled with some gibberish logs of errors, but you will always find a part of the error message that is meaningful. Right the compiler is telling, the syntax is deprecated and you *must* use new syntax – mfaani Oct 25 '16 at 18:08
  • Sorry it was just that I am very new to swift and didn't know how to format it. Thank you for the advice – John Smith Oct 25 '16 at 20:38

1 Answers1

3

Use the arc4random method:

let sessionID = Int(arc4random_uniform(50000))
Rashwan L
  • 38,237
  • 7
  • 103
  • 107