Alright, I'll try and make this as simple as possible (I was seeming to get the run around on chat.stackoveflow.com when I tried asking this question). I want to pass the text from a textfield in one viewcontroller to another viewcontroller.
Should I use a Model class and store the the textfield.text in a Model.[h/m] files and then have the second view controller access the data stored in the model?
Basically this is what I have,
ViewControllerWelcome.h
@interface ViewControllerWelcome : UIViewController { }
@property (weak, nonatomic) IBOutlet UITextField *textFieldUsername;
ViewControllerWelcome.m
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
ViewControllerHome *home = (ViewControllerHome *)[storyboard instantiateViewControllerWithIdentifier:@"Home"];
NSString *username = _textFieldUsername.text;
home.lblUSERNAME.text=username;
[self presentModalViewController:home animated:YES];
ViewControllerHome.h
@interface ViewControllerHome : UIViewController {
NSString *username;
UILabel *lblUSERNAME;
}
@property (weak, nonatomic) IBOutlet UILabel *lblUSERNAME;
ViewControllerHome.m
- (void)changeUSERNAME {
// get username from welcome tf
ViewControllerWelcome *welcome = [[ViewControllerWelcome alloc] init];
welcome.username = [self lblUSERNAME.text];
// _lblUSERNAME.text = welcome._textFieldUsername.text;
//welcome.textFieldUsername.text = _username;
// username = welcome.textFieldUsername.text;
NSLog(@"username = %@",username);
// welcome.textFieldUsername.text = _lblUSERNAME.text;
// NSLog(@"username = %@",welcome.textFieldUsername.text);
}
As you can see I tried several different things, but couldn't come up with a working solution :-l