我是 Objective-C 和 Xcode 的新手,我正在尝试使用主视图控制器中的“prepareforsegue”方法传递数组行索引。然后我将索引值插入到一个小的 sqlite3 表中,以便详细视图控制器显示正确的数据行。项目没有错误,但崩溃:
'NSRangeException',原因:' * -[__NSArrayM objectAtIndex:]:索引 6194506 超出范围 [0 .. 1]'
这是prepareforsegue代码:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"showDetail"])
{
NSIndexPath *selectedRowIndex = [self.tableView indexPathForSelectedRow];
FEIViewController *destViewController = segue.destinationViewController;
NSInteger row = selectedRowIndex.row;
destViewController.rowNumber = &(row);
}
}
这是 viewDidLoad 代码:
- (void)viewDidLoad
{
int myRowInt = *(_rowNumber);
FEIMyList * myFEI =[[FEIMyList alloc] init];
self.feig = [myFEI getMyFEI];
[self.feigImage setImage:((FEIList *) [self.feig objectAtIndex:myRowInt]).image];
[self.feigAction setText:((FEIList *) [self.feig objectAtIndex:myRowInt]).action];
[self.feigOther setText:((FEIList *) [self.feig objectAtIndex:myRowInt]).other];
[self.feigCondition setText:((FEIList *) [self.feig objectAtIndex:myRowInt]).condition];
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}