Hi,
I have an UIPickerView with 2 components. I would like to save the user's selection and to apply it next time the pickerView is shown again.
Here's my code:
And...
The problem is that this NSUserDefaults settings don't save the UIPickerView selections.
My pickerView has 2 components.
Thanks
I have an UIPickerView with 2 components. I would like to save the user's selection and to apply it next time the pickerView is shown again.
Here's my code:
Code:
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
NSUserDefaults *pickerViewSelectionDefaults = [NSUserDefaults standardUserDefaults];
[pickerViewSelectionDefaults setInteger:row forKey:@"pickerViewSelectionKey"];
[pickerViewSelectionDefaults synchronize];
}
}
And...
Code:
- (void)viewWillAppear:(BOOL)animated {
NSUserDefaults *pickerViewSelectionDefaults = [NSUserDefaults standardUserDefaults];
[pickerView selectRow:[pickerViewSelectionDefaults integerForKey:@"pickerViewSelectionKey"] inComponent:0 animated:YES];
}
The problem is that this NSUserDefaults settings don't save the UIPickerView selections.
My pickerView has 2 components.
Thanks