Marty
Marty

Reputation: 6184

How to show a message only the first time an app is launched?

Is there an easy way to have an alert appear only the first time an app is launched, or will I have to do it manually by making a BOOL and having it set to FALSE after it's run the first time?

Upvotes: 1

Views: 375

Answers (1)

Joseph Tura
Joseph Tura

Reputation: 6360

Sounds easy enough...

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

if(![defaults boolForKey:@"hasBeenLaunchedBefore"]) {
  //Show alert
  [defaults setBool:YES forKey:@"hasBeenLaunchedBefore"];
  [defaults synchronize];
}

Upvotes: 5

Related Questions