Hi,
I have an UIPickerView with 2 components. I save the user picker selection with NSUserDefaults. Both components have the save rows text.
For some reason, it saves only the last selected row and apply it on the other component, for example: If I select row 0 in component 0 and then select row 1 in component 1, and try to access them again it selects row 1 in both components instead of row 0 & row 1.
Here's my saving code:
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
NSUserDefaults *pickerSelectionDefaults = [NSUserDefaults standardUserDefaults];
[pickerSelectionDefaults setInteger:row forKey:@"leftComponentSelectionKey"];
[pickerSelectionDefaults setInteger:row forKey:@"rightComponentSelectionKey"];
[pickerSelectionDefaults synchronize];
}
- (void)viewWillAppear:(BOOL)animated {
NSUserDefaults *pickerSelectionDefaults = [NSUserDefaults standardUserDefaults];
[enginesPicker selectRow:[pickerSelectionDefaults integerForKey:@"leftComponentSelectionKey"] inComponent:0 animated:YES];
[enginesPicker selectRow:[pickerSelectionDefaults integerForKey:@"rightComponentSelectionKey"] inComponent:1 animated:YES];
}
Thanks!