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

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

Draw This
($0.99)

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

Pic Frame Dynamo: Photo Editing
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 07-06-2009, 10:03 PM   #1 (permalink)
aaronsbush
Registered Member
 
Join Date: Feb 2009
Posts: 19
aaronsbush is on a distinguished road
Default User Defaults question - so confused!

More newbie questions... I have several bool functions that if selected change the sate of a button. Here is some of the code:
if (checkboxSelected == 0){
[checkboxButton setSelected:YES];
} else {
checkboxSelected = 1;
[checkboxButton setSelected:NO];
}
}

I want a user to be able to save the state of the bool and the corresponding state of the button that is affected by the bool. I am also using the NSUserDefaults to save information from textFields elsewhere in my app using this type of code:
//Saving the default settings
NSUserDefaults *Prefs = [NSUserDefaults standardUserDefaults];
[Prefs setObject:inputField.text forKey:@"savedData"];
defaultSettings.text = @"Saved!";
//Loading the default settings
NSUserDefaults *Prefs = [NSUserDefaults standardUserDefaults];
NSString *Defaults = [Prefs stringForKey:@"savedData"];
if(Defaults == nil) {
defaultSettings.text = @"";
} else {
inputField.text = [[NSString alloc] initWithFormat:@"%@", Defaults];
}

That works great, but I have been unable to figure out the code for the bool functions. Can anyone point me to a tutorial or help clarify the code necessary? I've been Apple's dev center but now am even more confused.

Thanks in advance for your help.
aaronsbush is offline   Reply With Quote
 

» Advertisements
» Online Users: 562
21 members and 541 guests
Alexj17, armmzz, avors, baja_yu, bazookaBen, chiataytuday, ditren, Droverson, G-Power, givensur, hambeast, idiot_2008, ITCreative, KZS, lavontn96, linda368, linkmx, michaelhansen, oceanlablight, Rudy, wildvlad
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 174,541
Threads: 93,723
Posts: 401,259
Top Poster: BrianSlick (7,954)
Welcome to our newest member, linda368
Powered by vBadvanced CMPS v3.1.0

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