Alex Crawford
Alex Crawford

Reputation: 321

How to only display a message once on app start up?

How would i display a UIImageView only when my app is first started ?

Upvotes: 1

Views: 705

Answers (2)

Rog
Rog

Reputation: 18670

Use NSUserDefaults to set a BOOL flag like "firstStart" to YES/NO and read that value on applicationDidFinishLaunch:.

If YES, run your first message method and if NO continue with a normal run.

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]
if ([defaults boolForKey:@"firstStart"] == YES)
{
      [self firstStartMessage];
      [defaults setValue:NO forKey:@"firstStart"];
}

Upvotes: 1

Anomie
Anomie

Reputation: 94804

Once, the first time the app is started on the device? Set a flag in NSUserDefaults to indicate that the message has been shown already.

Once each time the app is started? Put a flag ivar in your app delegate or root view controller, or even use a global variable.

Upvotes: 0

Related Questions