Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 01-19-2010, 05:41 AM   #5 (permalink)
gerakis
Registered Member
 
Join Date: Jan 2010
Posts: 12
gerakis is on a distinguished road
Default

I doubt you still care about this, but I think I know whats wrong. You have to add in a few lines to deal with the applicationWillTerminate part.

Code:
-(void)applicationDidFinishLaunching:(UIApplication *)app {
	
    NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
	
    SwitchOne.on = [defs boolForKey: @"MYSwitchOne"];
    SwitchTwo.on = [defs boolForKey: @"MYSwitchTwo"];

//for activating the state saver later
	UIApplication *app = [UIApplication sharedApplication];
	[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillTerminate:) name:UIApplicationWillTerminateNotification object:app];
}

-(void)applicationWillTerminate:(UIApplication *)app {
	
    NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
	
    [defs setBool: SwitchOne.on forKey: @"MYSwitchOne"];
    [defs setBool: SwitchTwo.on forKey: @"MYSwitchTwo"];

    [[NSUserDefaults standardUserDefaults] synchronize];


}
gerakis is offline   Reply With Quote
 

» Advertisements
» Online Users: 448
16 members and 432 guests
acegames, baja_yu, Bobarino, David-T, djbrooks111, esoteric, HemiMG, ilmman, inkcpp, jimmyon122, kilobytedump, minglei, Nuncha, PowerGoofy, taewhan
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,433
Threads: 94,026
Posts: 402,588
Top Poster: BrianSlick (7,978)
Welcome to our newest member, caraldo32
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 07:42 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.