I have a problem with my UIPickerView.
I have 3 values in it EU AP and NA.
When I start the app EU seems to be selected but when I make a NSLog(@"%@", [regions objectAtIndex:row]); I only get back (null),
now when I touch the UIPickerView the EU value is selected and I get "EU" back from a NSLog.
My question is:
How can I define a default value which is selected (not only the label) when the user only starts the app and touches nothing.
Edit: Here is my code to get the selected item:
#pragma mark -
#pragma mark PickerView DataSource
- (NSInteger)numberOfComponentsInPickerView:
(UIPickerView *)pickerView
{
return 1;
}
- (NSInteger)pickerView:(UIPickerView *)pickerView
numberOfRowsInComponent:(NSInteger)component
{
return [regions count];
}
- (NSString *)pickerView:(UIPickerView *)pickerView
titleForRow:(NSInteger)row
forComponent:(NSInteger)component
{
return [regions objectAtIndex:row];
}
#pragma mark -
#pragma mark PickerView Delegate
-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row
inComponent:(NSInteger)component
{
selectedRegion = [[NSString alloc] initWithFormat:
@"%@", [regions objectAtIndex:row]];
NSLog(@"%@", selectedRegion);
}