重複の可能性:
View Controller 間でのデータの受け渡し
私は2つのView Controllerを持っています:
- 索引
- 2番
インデックスには 2textfieldとがありbuttonます。
このテキスト フィールドに入力し、「次へ」ボタンを押して 2 番目のビューに移動します。配列を使用して、この 2 つのテキスト フィールドを「表示」する必要があります (後で JSON データを送信します)。どうすれば最もよく理解できますか?助けてください!よろしく
イヴァン。
@propertyクラス内Secondを として宣言しtextArrayます。そして、SecondfromIndexにプッシュするときに、このプロパティを設定する必要があります。
Second.hファイルでは、
@property(nonatomic, strong) NSArray *textArray;
Index.mファイルでは、
Second *aSecond = [[Second alloc] init];
aSecond.textArray = @[textField1.text, textField2.text];
//write code to push from Index to Second
クラスでは、次のようにSecond使用できます。aSecond.textArray[0]aSecond.textArray[1]