I have 2 view controller:
Index
Second
In Index I have 2 textfield and button.
I fill this text field and press “next button” to second view, I need to “show” this two text field, by using Array (later I will send JSON data).
I Tried this:
Declare an @property in class Second as textArray. And then while pushing to Second from Index, you need to set this property.
In Second.h file,
@property(nonatomic, strong) NSArray *textArray;
In Index.m file,
Second *aSecond = [[Second alloc] init];
aSecond.textArray = @[textField1.text, textField2.text];
//write code to push from Index to Second
Now in class Second, you can use it as aSecond.textArray[0] and aSecond.textArray[1]
But if i switch page (click next) array has been nulled.
For switch page i use this:
SecondPage *SecondPage = [self.storyboard instantiateInitialViewController];
SecondPage = [self.storyboard instantiateViewControllerWithIdentifier:@"SecondPage"];
[self SecondPage animated:YES];
How I can best realize? Please help! Best regards
Ivan.
There are lot of ways to transfer the value from one controller to an other, but for you I think this will be the most simple ever. Use
NSUserDefaultsFirst Easy Ways
in first Controller
in 2nd Controller
2nd Easy ways is