0
私はテーブルビューを持っています。テーブルビューセルがクリックされると、特定のテキストラベル値を取得します。 APIRequest.mファイルには、変数shipmentReferenceNo
があり、その値imはdidSelectRowAtIndexPathのtextlabel値として割り当てられています。私はdidSelectRowAtIndexPath
で以前にそれを割り当てたものの、次のようにAPIRequest.mファイルから次のようにshipmentReferenceNoにアクセスしようとしているイム、そのヌルdidSelectRowAtIndexPathによって値を渡すことができません
NSLog(@"sd %@",self.shipmentReferenceNo);
このNULL値の可能な理由は何ができるか
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;
{
tabBar = [self.storyboard instantiateViewControllerWithIdentifier:@"TabBarController"];
[self.navigationController pushViewController:tabBar animated:YES];
[tableView deselectRowAtIndexPath:indexPath animated:YES];
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
UILabel *label = (UILabel *)[cell viewWithTag:123123];
self.request = [[APIRequest alloc]init];
self.request.shipmentReferenceNo = label.text;
NSLog(@"hello %@", label.text);
}
?
これは、新しいインスタンスを再度作成するためです。 self.request = [[APIRequest alloc] init]; self.requestをプロパティとして宣言しているので、self.request.shipmentReferenceNoではなくself.shipmentReferenceNoを探す必要があります –
私はそれを試しましたが、同じ問題を抱えています。 – user1241241
didSelectメソッドにブレークポイントを入れるデバッガでself.requestの値を表示しようとします。 –