List of already shown questions in my quiz

Hi! I'm a beginner in making apps. I'm making a quiz app, but I have a problem. To avoid questions are shown twice in my quiz, I would set a list with the already shown questions.
Does anyone know how to do this?

Here's some code:

struct Question {
    let text: String
    let answers: [Answer]
	}
    struct Answer {
    let text: String
    let correct: Bool
	}
private func ConfiqureUI(question: Question){
        label.text = question.text
        label.adjustsFontSizeToFitWidth = true
        CurrentQuestion = question
        table.reloadData()
    }
let NextQuestion = allQuestions.randomElement()
                    print("\(NextQuestion!.text)")
                    CurrentQuestion = nil
                    ConfiqureUI(question:NextQuestion!)
                    Progress += 1
                    updateLabel()

Thanks in advance!

Why don’t you remove your Question from the Array when you get it, so your Array is only a list of unasked questions? (Or make a duplicate array that is unasked questions, or at least a collection of unasked question index numbers.)

Terms of Service

Privacy Policy

Cookie Policy