I’m trying to do show an alert the first time the app is launched. I’d also like to show this alert if they go into a settings page later on and want to see it again. I figured I could set a boolean in the NSUserDefaults. I’m not quite sure how to do that though (assuming this approach is right). I thought in applicationDidFinishLaunching:options, I could get the value for key @"FirstTimeLaunched", and in applicationWillTerminate, I could set the object for that key to NO. If this is the case, how do I get the BOOL to be YES for the first time?
Also, do I need to set it to NO in didEnterBackground mode as well? Thanks.
Just think it backwards, instead of expecting a
YES, set a variable when the app is actually launched, and remove it when the user says so in the settings.At launch:
And when the user wants to see it again, just remove the key:
When accessing a key that does not exists,
NSUserDefaultswill returnnil.