Ios indexPath.row上的prepareForSegue EXC_错误访问
我试图通过prepareForSegue函数下的一个序列传递数据,但我一直在获取exc_bad_访问权限Ios indexPath.row上的prepareForSegue EXC_错误访问,ios,objective-c,iphone,xcode,xcode8,Ios,Objective C,Iphone,Xcode,Xcode8,我试图通过prepareForSegue函数下的一个序列传递数据,但我一直在获取exc_bad_访问权限 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow]; //NSIndexPath *indexPath = [NSIndexPath indexPathForRow:r
- (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;
}
}
下面是我犯的错误
编辑:
库存清单声明如下:
@interface downloadInv (){
NSMutableArray *inv_list;
}
@interface itemList : UITableViewController
@property(nonatomic, strong) NSString *inv;
@end
在viewDidLoad中:
inv_list = [[NSMutableArray alloc] init];
内容:
vc.inv是inv_列表中的一个特定元素,我希望在选择表时将其传递给目标视图控制器
声明如下:
@interface downloadInv (){
NSMutableArray *inv_list;
}
@interface itemList : UITableViewController
@property(nonatomic, strong) NSString *inv;
@end
有人知道怎么解决这个问题吗
提前感谢。因为列表中的
未声明为强属性,所以可能正在发布。
尝试这样声明:
@property(强,非原子)NSMutableArray*inv\u列表代码>请检查您的序列标识符,如果没有给出,可能会导致异常
否则,如果它是强属性,如:
@property(nonatomic,strong) NSString *inv_list;
它可以解决问题。什么是inv\u list
?它是数组吗?确保您在prepareforsegue
中获得了正确的indexpat,而不是零!请说明inv\u list
是如何定义的?告诉我们列表是什么,以及您试图填充的vc的属性是什么。尝试将其声明为强属性根据代码,inv\u list根本没有声明为属性,请尝试@property(强,非原子)NSMutableArray*inv\u list;