【发布时间】:2017-05-16 07:25:44
【问题描述】:
我正在尝试通过 prepareForSegue 函数下的 segue 传递数据,但我不断收到 exc_bad_access。
- (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;
}
}
下面是我遇到的错误
编辑: inv_list 声明如下:
@interface downloadInv (){
NSMutableArray *inv_list;
}
在 viewDidLoad 中:
inv_list = [[NSMutableArray alloc] init];
内容:
vc.inv 是 inv_list 中的一个特定元素,我想在选择表时将其传递给目标视图控制器。
声明如下:
@interface itemList : UITableViewController
@property(nonatomic, strong) NSString *inv;
@end
有人知道如何解决这个问题吗?
提前致谢。
【问题讨论】:
-
inv_list是什么?它是数组吗?确保您在prepareforsegue中获得了正确的 indexpat 而不是 nil! -
请说明
inv_list是如何定义的? -
向我们展示列表是什么,以及您要填充的 vc 的属性是什么。
-
尝试将其声明为强属性
-
根据代码,inv_list根本没有声明为属性,试试@property (strong, nonatomic) NSMutableArray * inv_list;
标签: ios objective-c iphone xcode xcode8