I am a bit stuck on trying to pass data from two UITextfields on one viewcontroller to another viewcontroller. Basically I got the items below:
ViewController.h
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController {
IBOutlet UITextfield *Textfield1;
IBOutlet UITextfield *Textfield2;
}
-(IBAction)GoNextView:(id)sender;
@end
ViewController.m
@interface ViewController ()
@end
@implementation ViewController
(IBAction)GoNextView:(id)sender {
SecondView *second = [[SecondView alloc] initWithNibName:nil bundle:nil];
[self presentViewController:second animated:YES completion:NULL];
}
- (void)viewDidLoad {
[super viewDidLoad];
}
SecondView.h
#import <UIKit/UIKit.h>
@interface SecondView : UIViewController {
IBOutlet UILabel *ShowTextfield1;
IBOutlet UILabel *ShowTextfield2;
}
-(IBAction)GoBack:(id)sender;
@end
SecondView.m
@interface SecondView ()
@end
@implementation SecondView
- (IBAction)GoBack:(id)sender {
[self dismissViewControllerAnimated:YES completion:NULL];
}
What I want is, that when the button GoNextView
is pressed it should pass the data in the UITextfield
to the SecondView
. And the go to the next page. The data should now be displayed in the two Labels on the SecondView
. I've been struggling with this for many hours now and its killing me. I know I have to use some NSString
and @property(nonatomic, retain) NSString *asdas
. But I simply can't make it work. So based on the above code how do I pass data from the two UITextfield
to the two labels on the next view?