在IOS项目中传递dex号码(主 - 细节)

时间:2012-06-26 16:15:54

标签: objective-c

我是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.

}

1 个答案:

答案 0 :(得分:0)

您的myRowInt设置不正确。尝试在目标视图控制器上创建NSNumber作为属性,然后在prepareForSegue中设置它。