mercredi 7 août 2019

How to pull random questions for quizz app from an array in questionbank? Swift

So I am working on my first personal project (includes a quiz feature), while at the same time taking a swift course. I am trying to figure out, how to randomize the arrays.

I've found a few videos explaining something similar, but nothing seems to work for me.

This is an example of one of my question banks that needs to be shuffled.

class ImageQuestionBank {
var list = [ImageQuestion] ()
init () {
    let item = ImageQuestion(qtext: "Example Question?", image: "image1", correctAnswer: true)
    list.append(item)
    list.append(ImageQuestion(qtext: "Example Question?", image: "image2", correctAnswer: false))
    list.append(ImageQuestion(qtext: "Example Question?", image: "image3", correctAnswer: true))
    }
}




Aucun commentaire:

Enregistrer un commentaire