Show screen on first launch only in iOS

I’m assuming by Xcode you actually mean iOS.

What you need to do is use the NSUserDefaults class to store a flag indicating whether the user has seen the tutorial screen before.

When your app first loads (or at the point you want to decide whether or not to show the tutorial screen), do something like this:

if(![[NSUserDefaults standardUserDefaults] boolForKey:@"hasSeenTutorial"])
    [self displayTutorial];

This checks the saved NSUserDefaults for the current user for a value named “hasSeenTutorial”, which won’t exist yet. Since it doesn’t exist, it will call displayTutorial. displayTutorial refers to your method for creating the tutorial view. You can figure out that part.

Then, once the user closes the tutorial screen:

[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"hasSeenTutorial"];

That value will be saved for your user profile, meaning the next time it checks it, it will be true, so displayTutorial won’t be called.

Leave a Comment