The functionality I'm trying to get to is to default the state of my switch to setOn:YES but once the user toggles the UISwitch save the state of that switch in NSUserDefaults.
How would I best go about this in my view? I currently have the code below in my viewDidLoad:
if([[NSUserDefaults standardUserDefaults] boolForKey:@"lights"] == 0){
[lightsSwitch setOn:NO];
}
and in my toggleLightSwitch:(id)sender:
[[NSUserDefaults standardUserDefaults] setBool:lightsSwitch.isOn
forKey:@"lights"];
but the functionality will be to default to setOn:NO. Since NSUserDefault defaults to NO for a bool key, is there a way I can fix this?