title: Passing data between view controllers - iOS Xcode - what's a good way?
body: <p>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.</p>
  
  <p>Should I use a <em>Model</em> 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?</p>
  
  <p>Basically this is what I have,</p>
  
  <p><strong>ViewControllerWelcome.h</strong></p>
  
  <pre><code>@interface ViewControllerWelcome : UIViewController { }
  
  @property (weak, nonatomic) IBOutlet UITextField *textFieldUsername;
  </code></pre>
  
  <p><strong>ViewControllerWelcome.m</strong></p>
  
  <pre><code>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];
  </code></pre>
  
  <p><strong>ViewControllerHome.h</strong></p>
  
  <pre><code>@interface ViewControllerHome : UIViewController {
  NSString *username;
  UILabel *lblUSERNAME;
  }
  
  @property (weak, nonatomic) IBOutlet UILabel *lblUSERNAME;
  </code></pre>
  
  <p><strong>ViewControllerHome.m</strong></p>
  
  <pre><code>- (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);
  }    
  </code></pre>
  
  <p>As you can see I tried several different things, but couldn't come up with a working solution :-l</p>