I have a game that is based on attempts rather than score. And I wish to display a pop up every 10 attempts. What is the best way, using Swift, to calculate every 10 intervals of something?
Currently I call a function to increment the attempts value which includes: gamesPlayedSaved += 1
. The closest question I found on here uses timers, which wouldn't work in my case.
So far, I have this (WHICH IS EXTREMELY UGLY):
if(gamesPlayedSaved == 10 ||
gamesPlayedSaved == 20 ||
gamesPlayedSaved == 30 ||
gamesPlayedSaved == 40 ||
gamesPlayedSaved == 50 ||
gamesPlayedSaved == 60 ||
gamesPlayedSaved == 70 ||
gamesPlayedSaved == 80 ||
gamesPlayedSaved == 90 ||
gamesPlayedSaved == 100){
// call pop up
}
And it also doesn't account for any intervals over 100.