2017-05-16 3 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

EDIT:

@interface downloadInv(){ 
NSMutableArray *inv_list; 
} 

をとのviewDidLoadで: inv_listのように宣言され、その後

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

それが与えられていない場合は、お使いのセグエ識別子を確認してくださいでしたそれはのように強力なプロパティとして作られている場合はそうでない場合は例外

を引き起こす可能性があります。

@property(nonatomic,strong) NSString *inv_list; 

問題を解決する可能性があります。