-5

What am I doing wrong? It won't let me use random.

PickRandom()

func PickRandom() {
    let RandomNumber = random() % QuizObject.count // error here
    Btn1.setTitle(QuizObject[RandomNumber].Answers[0])
    Btn2.setTitle(QuizObject[RandomNumber].Answers[1])
    Btn3.setTitle(QuizObject[RandomNumber].Answers[2])
    Btn4.setTitle(QuizObject[RandomNumber].Answers[3])
    QuestionLabel.setText(QuizObject[RandomNumber].Question)
    RealAnswer = QuizObject[RandomNumber].Answer
}

func RightWrong(){
    if (NumberPicked == RealAnswer) {
        PickRandom()
        QuestionLabel.setTextColor(UIColor.white)
    } else {
        QuestionLabel.setTextColor(UIColor.red)
    }
}
rmaddy
  • 314,917
  • 42
  • 532
  • 579
  • 2
    1) Next time, please format your code. 2) Update your question with the error message. – rmaddy Nov 19 '16 at 03:50
  • 1
    And you may wish to review http://stackoverflow.com/questions/24007129/how-does-one-generate-a-random-number-in-apples-swift-language – rmaddy Nov 19 '16 at 03:52

1 Answers1

0

Write import Darwin and use arc4random() instead of random()... This will resolve your error

haider_kazal
  • 3,448
  • 2
  • 20
  • 42