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.
|