is there a first time launch method that is called only the first time the app is opened. becuase i have to set some variables, but i want them to be able to change and not revert back to what i set them to.
I answered a post with this exact same question a while ago, see if you can find it :P
Basically, the idea was to create a plist. When you first run the app, the plist wont exist, so all of the variables you try to recieve will be nil, NO, etc. the best way was to make a bool and save it using NSUserDefaults. retrieve that when your view controller loads, and if it is NO, then that is the first time the app has been run. make sure you set it to yes later
ok lets see here...
in your viewdidLoad, or wherever you want it
Code:
BOOL hasRunBefore = [[NSUserDefaults standardUserDefaults] boolForKey:@"FirstRun"];
if (hasRunBefore) {
****NOT the first time
}
else if (!hasRunBefore) {
****DO YOUR SETUP HERE
}
I think that should work. I wrote it off the top of my head (im not on my mac) so there may be some typos, but thats the idea
Use NSUserDefaults to determine whether it's the first launch.
On first launch, simply set a bool (or something else if you prefer) using the setBool:forKey: method. If it doesn't exist yet when your app launches, you know it's the first launch.
Rather than just saving a BOOL, I actually save that application bundle's version number string into defaults.
This provides some future proofing so that not only can you check if the app has been run before, you can check which version was last run. Sometimes this information is very useful indeed.