How to make data transfer between ViewController , i.e. from one controller to another?
I want to make data entry (settings) on one controller, and output this data on the other.
If you can, tell me an example, please!
ViewController.h #import <UIKit/UIKit.h> #import "ViewController2.h" @interface ViewController : UIViewController @property (weak, nonatomic) IBOutlet UITextField *log; - (IBAction)vper:(id)sender; @end ViewController.m #import "ViewController.h" @interface ViewController () @end @implementation ViewController - (void) someButtonTapped:(id)sender { ViewController2 *classB = [[ViewController2 alloc] init]; //создаете экземпляр класса classB.textFieldValue = _log.text; // присваеваете значение переменной } - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (IBAction)vper:(id)sender { } @end ViewController2.h #import <UIKit/UIKit.h> #import "ViewController.h" @interface ViewController2 : UIViewController @property (nonatomic, strong) NSString *textFieldValue; @property (weak, nonatomic) IBOutlet UILabel *lab; - (IBAction)naz:(id)sender; @end ViewController2.m #import "ViewController2.h" @interface ViewController2 () @end @implementation ViewController2 - (void)viewDidLoad { NSLog(@"textFieldValue = %@", _textFieldValue); } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (IBAction)naz:(id)sender { } @end 