I am using the following code in a quiz, where once the user answers the question an alert pops up. They then have the option to go to the next question OR review the question again and then after a time period the next question appears.
The issue I am having is that this action carries on to the next question and skips it after the time period, not allowing the user time to answer it! Whats the best way to stop the action repeating automatically in the following questions?
func nextTapped() {
DispatchQueue.main.asyncAfter(deadline: .now() + 10.0) {
nextQuestion()
}
}
func continueTapped() {
nextQuestion()
}
.alert(isPresented: $showingFeedback) {
Alert(
title: Text(scoreTitle),
message: Text(selectedQuestion!.feedback),
primaryButton: .default(Text("Review"), action: nextTapped),
secondaryButton: .default(Text("Continue"), action: continueTapped)
)
}