IOS app sends warning only for the first time using app

I would like to display a warning when the user first opens the application. After they open the application, they click on the button that pops up the table view on the navigation controller stack. If this is the first time a table view has ever been opened, a warning view should appear that displays a message to the user that they can click the cell to edit.

How can i achieve this?

thanks

+4
source share
2 answers

Just use NSUserDefaults .

sort of:

 // 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]; } 
+13
source

When your user clicks on your button, you should check some value in [NSUserDefaults standardDefatults] , if the check is zero, you should display your warning, and then save some value, so the next time it checks, it will make a difference and you donโ€™t have anything are doing.

Like this:

 NSString * val = [[NSUserDefaults standardUserDefaults] objectForKey:@"kFirstTime"]; if (!val) { //show alert [[NSUserDefaults standardUserDefaults] setObject:@"1" forKey:@"kFirstTime"]; [[NSUserDefaults standardUserDefaults] synchronize]; } //Your code 
0
source

All Articles