I am using an UISegmentedControl with two sections: the first is Don’t Remember Password and the second is Remember Password. If they select Remember Password, I use NSUserDefaults to remember this. On startup, how do I make Remember Password selected if NSUserDefaults is YES?
if ([[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"Remember password"] == YES)
{
//Make the second segment (segment 1 as it would be called, since first is segment 0) selected
}
It is as simple as setting selectedSegmentIndex inside of viewDidLoad to ensure that the segment is not nil.
Also why not use a
UISwitchand set theonvalue directly to the stored value?