私の用語が少しずれている場合はお詫びします。Objective C は初めてです。ある UIViewController クラスから別のクラスに値を渡そうとしています。ストーリーボードを使用しています。次のコードを使用して、2 番目の ViewController を表示できます。
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController *vc = [mainStoryboard instantiateViewControllerWithIdentifier:@"FormView"];
[self presentModalViewController:vc animated:YES];
それはうまくいきます。2 番目の ViewController の (FormView) ヘッダー ファイルで、次のようにプロパティを設定します。
@interface FormController : UIViewController {
NSString *selectedBooking;
}
@property (nonatomic, retain) NSString *selectedBooking;
@end
最初のコントローラーから 2 番目のコントローラーに「値を渡す」にはどうすればよいですか? 私が理解している限り、次のようにプロパティを設定する必要があります。
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController *vc = [mainStoryboard instantiateViewControllerWithIdentifier:@"FormView"];
vc.selectedBooking = @"test";
[self presentModalViewController:vc animated:YES];
これは私にエラーを与えます: プロパティ 'selectedBooking' がタイプ 'UIViewController' のオブジェクトに見つかりません。
プロパティを設定する正しい方法は何ですか? instantiateViewControllerWithIdentifier ではなく、他に使用すべきものはありますか?
ありがとう