Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS app sending an alert view only on the first time using the app

I would like to display an alertview when a user opens the app for the first time. After they open the app, they click on a button that pushes a table view on the navigation controller stack. If it's the first time the table view has ever been opened, there should be an alert view that displays telling the user that they can click the cell to edit.

How can I achieve this?

Thanks

like image 725
thebiglebowski11 Avatar asked Dec 13 '22 00:12

thebiglebowski11


1 Answers

Simply, use NSUserDefaults.

something like:

// the place where you want to check if this is the first run:
BOOL didRunBefore = [[NSUserDefaults standardUserDefaults] boolForKey:@"didRunBefore"];

if (!didRunBefore) {
    // show alert;
    [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"didRunBefore"];
    [[NSUserDefaults standardUserDefaults] synchronize];
}
like image 62
Mazyod Avatar answered May 14 '23 11:05

Mazyod