I have pickerView with two rows and I need to save position of both to NSUserDefaults. I have successful saved first row with this code:
- (void)pickerView:(UIPickerView *)thePickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
NSInteger selectedRow = [thePickerView selectedRowInComponent:0];
[[NSUserDefaults standardUserDefaults] setInteger:selectedRow forKey:@"picker"];
}
And I don’t get how to add a second one.
With this code I bring back the position:
-(void)viewWillAppear: (BOOL) animated {
NSUserDefaults *pickerViewSelectionDefaults = [NSUserDefaults standardUserDefaults];
[picker selectRow:[pickerViewSelectionDefaults integerForKey:@"picker"] inComponent:0 animated:YES];
[picker selectRow:[pickerViewSelectionDefaults integerForKey:@"picker"] inComponent:1 animated:YES];
}
Try this:
and this