Does anyone have decent code to run a function every n number of times a segue takes place? E.g. load an ad every time a user navigates 10 segues in my app.
At the moment I am doing something similar like so in my segue:
let chanceOfAd = Int(arc4random_uniform(UInt32(9)))
and then if the chanceOfAd == 0 , then I will load an ad. This is not ideal as it is a 1/10 chance of loading the ad, not every 10 segues. Of course this should average out the same amount of ad loads as if I did the every ten option, but some users will inevitably receive more ads than others, through the luck nature of the function at the moment.
So instead I want to load the ad every 10 times the segue takes place.