I have an array with multiple questions in it and once it shows the questions it removes it from the index not to be shown again. The problem is once the app restarts it doesn't save this. I need to be able to save it so it doesn't show a question already shown.
Here is the array:
questions = [question(question: "The Average Adult Human Body Contains 206 Bones", answers:["True","False"], answer: 0),
question(question: "Bees Have One Pair Of Wings", answers: ["True", "False"], answer: 1),
question(question: "The Shanghi Tower Is The Tallest Building In The World", answers: ["True", "False"], answer: 1),
question(question: "1024 Bytes Is Equal To 10 Kilobytes", answers: ["True", "False"], answer: 1)].....Plus More
Here is where I pick and then remove the question:
func pickQuestion() {
if questions.count > 0 {
questionNumber = Int(arc4random_uniform(UInt32(questions.count)))
questionLabel.text = questions[questionNumber].question
answerNumber = questions[questionNumber].answer
for i in 0..<trueorfalse.count {
trueorfalse[i].setTitle(questions[questionNumber].answers[i], for: UIControlState.normal)
}
//Here is where the question is removed from the array.
questions.remove(at: questionNumber)
}
}
Thanks.