Performing An Action Only the 1st Time Someone Opens Your Ap
I'm wondering if anyone knows how to only perform a certain action the first time someone opens the application. Say you want to display a welcome screen, only the first the the user opens the app, but never after that... how would you do that? Thank you very much!!!
I don't know if it will do the trick for you, but in your AppDelegate.m method you should have an applicationDidFinishLaunching method, where you can perform actions that only occurs just once the application is loaded for the first time, but never more, so you can just put the code you want here.
not on my mac atm so i cant see the correct capitalization/syntax and whatnot, but the first time the app launches it will check for a key on the device, since its the first time it wont be able to find it so it will return NO. at the end of whatever you do for the first launch set the value for that key to yes and the code wont run again.
not on my mac atm so i cant see the correct capitalization/syntax and whatnot, but the first time the app launches it will check for a key on the device, since its the first time it wont be able to find it so it will return NO. at the end of whatever you do for the first launch set the value for that key to yes and the code wont run again.
Thanks for the example, but just to clarify, say, I only want an alert to display the first time. Would the "do whatever" area be where I'd write the code I want implemented only on the first launch?
Thanks!
Thanks for the example, but just to clarify, say, I only want an alert to display the first time. Would the "do whatever" area be where I'd write the code I want implemented only on the first launch?
Thanks!
Yes, that is where you would do your first time operation. Just make sure you update the UserDefaults so it doesn't happen on subsequent launches:
COOL! Awesome,one more thing, can I also do it backwards? Say my normal code is what displays what I'd like the user to see the first time, do I then switch the if command to:
Code:
if(firstlaunch==YES)
to display the screen I'd like the user to see from there and after?