私は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.
}