2017-05-16 106 views
1

我想通过prepareForSegue函数中的segue传递数据,但我一直在获取exc_bad_access。prepareForSegue EXC_BAD_ACCESS at indexPath.row

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 

NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow]; 

//NSIndexPath *indexPath = [NSIndexPath indexPathForRow:rowIndex inSection:0]; 
// Make sure your segue name in storyboard is the same as this line 
if ([[segue identifier] isEqualToString:@"itemListSegue"]) 
{ 
    itemList *vc = [segue destinationViewController]; 
    vc.inv = [inv_list objectAtIndex:indexPath.row]; 
    vc.title = vc.inv; 
} 
} 

波纹管是我得到了错误

enter image description here

编辑: inv_list声明如下:

@interface downloadInv(){ 
NSMutableArray *inv_list; 
} 

在viewDidLoad中:

inv_list = [[NSMutableArray alloc] init]; 

内容:

enter image description here

vc.inv是在inv_list特定元件,我想当选择一个表,传递到目的地视图控制器。

它被宣布如下:

@interface itemList : UITableViewController 

@property(nonatomic, strong) NSString *inv; 
@end 

enter image description here

任何人都知道如何解决这一问题?

在此先感谢。

+1

什么是inv_list?它是数组吗?确保你在'prepareforsegue'中获得了正确的indexpat而不是零! – Lion

+1

请说明如何定义inv_list? –

+0

向我们展示列表是什么,以及您尝试填充的vc属性是什么。 –

回答

0

由于in_list未被宣告为强属性,因此可能会被释放。如果它是由强劲性能像

@property (strong, nonatomic) NSMutableArray * inv_list;

0

能否请您检查您的SEGUE标识,如果不是给予,可能会造成异常

否则:

@property(nonatomic,strong) NSString *inv_list; 
尝试宣告它像这样

它可以解决问题。