Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making an Alert apper after a certain amount of lanuches

I am working on this idea where I want an UIAlert to pop up after a certain amount of launches of the app (let's say after 20 launches).

And there's going to be 2 buttons. One that will reset the counter which will make the alert appear after another 20 launches. And one button that will make it disappear and never appear again.

How I would do this?

like image 564
inFever Avatar asked May 06 '11 11:05

inFever


1 Answers

Take a look at NSUserDefaults to store a count of the number of times the app has started.

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
uint count = [defaults integerForKey:@"num_launches"];

if (count > 20) {
    // Show alert
} else {
   count ++;
   [defaults setInteger:count forKey:@"num_launches"];
}
like image 56
deanWombourne Avatar answered Sep 19 '22 17:09

deanWombourne