在indexPath.row上准备FORSegue EXC_BAD_ACCESS

时间:2017-05-16 07:25:44

标签: ios objective-c iphone xcode xcode8

我正在尝试通过prepareForSegue函数下的segue传递数据,但我一直在获取exc_bad_access。

"Red Hat Enterprise Linux"
"c4.xlarge"
0.183

贝娄是我得到的错误

enter image description here

修改 inv_list声明如下:

- (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;
}
}

并在viewDidLoad中:

@interface downloadInv (){
NSMutableArray *inv_list;
}

内容:

enter image description here

vc.inv是inv_list中的一个特殊元素,我想在选择表时传递给目标视图控制器。

声明如下:

inv_list = [[NSMutableArray alloc] init];

enter image description here

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

提前致谢。

2 个答案:

答案 0 :(得分:1)

由于in_list未声明为强属性,因此可能正在释放。 试着像这样声明:

@property (strong, nonatomic) NSMutableArray * inv_list;

答案 1 :(得分:0)

Could you please check your segue identifier, If that's not given, may cause the exception

otherwise if it's made as strong property like:

@property(nonatomic,strong) NSString *inv_list;

It may solve the problem.