I have a problem that I have not seen addressed in this particular way before, so hopefully someone can help me with it. Let’s say I have a tab bar app with four views, one on each tab. Obviously the app will be forced to launch with the view controller it is told to launch with, but after that, it’s up to the user to select which tab (view) to load next.
The problem comes from the fact that I would like to show a view on each tab ONLY the first time that particular view is loaded. Normally, you’d do this:
BOOL foo = [[NSUserDefaults standardUserDefaults]boolForKey:@"previouslyLaunched"];
if (!foo)
{
NSLog(@"FirstLaunch");
[[NSUserDefaults standardUserDefaults]setBool:YES forKey:@"previouslyLaunched"];
///Do first run view initializaton here////
}
However, doing that once sets the NSUserDefault for all of the app, meaning that only the view for tab 1 will show and not the other three. So, my question is, how do I show a view for each of my four tabs only the first time each view loads? This is a complicated question because the user is able to select any tab in any order, so I can’t guide them down a path, I think.
Would I have to use a different key for each view? Would that work? It seems like that might be the best course of action here, but this is my first time working with NSUserDefaults, so I’m a little lost.
Any and all help is much appreciated!
Use a different key for each view:
e.g. viewController1PreviouslyLaunched, viewController2PreviouslyLaunched… etc