How do you make a button react to a certain command, only if it is clicked 4 times?

I am making a quiz app and I want the people to answer 4 multiple choice questions and after that they get redirected to a new screen with open questions. How do I do this? I have a button named nextQuestion and if that button is clicked 4 times I want it to go to a new screen..


I am pretty new to swift and xcode so im a bit clueless.

Replies

Use a counter, increment the counter when the button is pressed, check if the counter is over 3.


In fake code, something along the lines of:


var counter = 0

if (buttonPressed) {

counter++

}

If (counter >3){

counter = 0

goto next page

}


... maybe