You need two bool keys to be saved in NSUserDefaults to get the what you want. e.g. firstTime is used check first time app launch, showTutorial is used to check/save the switch change
You can set your boolean by using:
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"firstTime"];
and read it by using this code:
if([[NSUserDefaults standardUserDefaults] boolForKey:@"showTutorial"] || [[NSUserDefaults standardUserDefaults] boolForKey:@"firstTime"]) {
[self displayTutorial];
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"firstTime"];
}
else {
[self displayMainScreen];
}
Link the UISwitch on View from InterfaceBuilder to this action on valuechanged
-(IBAction)userSetOnOff:(id)sender
{
UISwitch *switchValue = sender;
if (switchValue.on){
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"showTutorial"];
}
else{
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"showTutorial"];
}
}