Created
July 24, 2012 14:53
-
-
Save dbaldwin/3170422 to your computer and use it in GitHub Desktop.
iOS gist for doing something only the first time an app is run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)viewDidLoad | |
{ | |
[super viewDidLoad]; | |
// Get a reference to the user defaults database | |
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; | |
// If this is the first run we're going into this if statement | |
if(![defaults objectForKey:@"firstRun"]) | |
{ | |
NSLog(@"This is the first run!!!!"); | |
// Set this and use later to determine what to do on first run | |
isFirstRun = TRUE; | |
// Persist the first run var so the next time we don't enter this if statement | |
[defaults setObject:[NSDate date] forKey:@"firstRun"]; | |
[[NSUserDefaults standardUserDefaults] synchronize]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment