我正在尝试禁用 UIPickerView 上的第 1 行,但它会引发以下错误
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 2147483647 beyond bounds [0 .. 15]'
任何人都可以建议我这里出了什么问题?这是代码
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
AppDelegate *appdelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
if ((row > 0)){
NSLog(@"%@",[locationArray objectAtIndex:row]);
if(flag){
appdelegate.selectedLocation = [locationArray objectAtIndex:row];
NSLog(@"%@",appdelegate.selectedLocation);
} else{
appdelegate.selectedLocation = [locationArray objectAtIndex:row];
NSLog(@"%@",appdelegate.selectedLocation);
}
[promptLocation addSubview:tapButton];
[tapButton addTarget:self action:@selector(goToDesireLoc:) forControlEvents:UIControlEventTouchUpInside];
}else{
//Don't do anything if row 0 is chosen.
NSLog(@"do nothing");
}
}