Top of the page
Close

This is a red error

This is a red error

This is a red error

Check the first launch of the application on iPhone (Objective-C, XCode, iPhone SDK)

Ondrej Rafaj on 2009.09.22 02:30:56

Really simple example how to check the first launch of the iPhone application written in Objective-C in XCode.

// applicationDidFinishLaunching from your main app delegate
- (void)applicationDidFinishLaunching:(UIApplication *)application {
	// ... standard apple code
    [[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], @"isFirstLaunch",nil]];
}


// to check the first launch in the code
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"isFirstLaunch"]) {
	 // place your code here
}


// put this code to your applicationWillTerminate function to set "isFirstLaunch" to NO after first launch
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"isFirstLaunch"];

Ondrej Rafaj

Ondrej Rafaj

Independent iPhone developer @ ondrej-rafaj.co.uk

I am available to give you a free quote or start working on your project ... just give me a call or drop a line. Please find all my details on my portfolio site ondrej-rafaj.co.uk

Back to top Comment

Comments ... Why not to get involved!

We had to disable comments till the problem with spam will be solved, sorry for any inconvenience caused.

Back to top

IE SUCKS, DON'T USE IT :) Digg this page