Reputation: 5426
I need to know if the App run for the first time to setup the Default settings something like music on/off Fx Volume equal to 0.5 ...
So is there any predefined way or I need to make it manually?
Upvotes: 2
Views: 223
Reputation: 7663
You can put this in your - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
:
if (![[NSUserDefaults standardUserDefaults] boolForKey:@"applicationRunBefore"]) {
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"applicationRunBefore"];
[[NSUserDefaults standardUserDefaults] synchronize];
// Application is running for the first time - do something
...
}
Hope that this helps...
Upvotes: 4
Reputation: 5546
The NSUSerDefaults does this for you already. The naming of methods is very confusing but essentially you set your default values at start up every time and the defaults that users set will automatically override them.
Upvotes: 4
Reputation: 8383
Try setting some value in userDefaults ..... If that value doesn't exits then Its running for first time also you can count total number of runs by regular updating that variable ...
Upvotes: 2