title: Passing Textfield Value to Label in another view Programmatically
body: <p>i am a newbie in iphone development and Xcode.
  and i am having a hard time running a simple demo app for passing my textfield text from one view to the label in another view programmatically....
  And i DONT know where i am going wrong [Even did NSLOG to check the string coming...it says Null :( ]</p>
  
  <p>See if you guys can help me find where i am lacking the code??
  Thanks in advance!</p>
  
  <p>Here is the thing i did:</p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  
  
  @interface ViewController : UIViewController&lt;UITextFieldDelegate&gt;{
      NSString *str;
  
  }
  @property(nonatomic,retain)NSString *str;
  
  @end
  </code></pre>
  
  <hr>
  
  <p><em><strong></em> ViewController.m <em>*</em></strong></p>
  
  <hr>
  
  <pre><code>#import "ViewController.h"
  #import "nextViewController.h"
  
  @interface ViewController ()
  
  @end
  
  @implementation ViewController
  @synthesize str;
  
  - (void)viewDidLoad
  {
  
      UITextField *txt =[[UITextField alloc]initWithFrame:CGRectMake(40, 40, 200, 30)];
      txt.borderStyle = UITextBorderStyleRoundedRect ;
      txt.delegate=self;
      [self.view addSubview:txt];
  
  
      UIButton *btn=[UIButton buttonWithType:UIButtonTypeRoundedRect];
      btn.frame = CGRectMake(80, 80, 200, 30);
      [btn setTitle:@"Press" forState:UIControlStateNormal];
      [btn addTarget:self action:@selector(btn:) forControlEvents:UIControlEventTouchUpInside];
      [self.view addSubview:btn];
  
      [super viewDidLoad];
  }
  
  - (BOOL)textFieldShouldEndEditing:(UITextField *)textField{
      self.str = [textField text];
      return YES;
  }
  
  -(IBAction)btn:(id)sender{
  
  
  
      nextViewController *next =[[nextViewController alloc]init];
  
  [self.navigationController pushViewController:next animated:YES];
  
  }
  </code></pre>
  
  <hr>
  
  <p><em><strong></em> nextViewController.h <em>*</em></strong></p>
  
  <hr>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  #import "ViewController.h"
  
  @interface nextViewController : UIViewController{
      NSString *str;
  }
      @property(nonatomic,retain)NSString *str;
  
  @end
  </code></pre>
  
  <hr>
  
  <p><em><strong></em> nextViewController.m <em>*</em></strong></p>
  
  <hr>
  
  <pre><code>#import "nextViewController.h"
  #import "ViewController.h"
  
  @interface nextViewController ()
  
  @end
  
  @implementation nextViewController
  @synthesize str;
  - (void)viewDidLoad
  {
      UILabel *lbl = [[UILabel alloc]init];
      lbl.frame=CGRectMake(40, 40, 200, 30);
      ViewController *VC =[[ViewController alloc]init];
      lbl.text=VC.str;`enter code here`
  
      [self.view addSubview:lbl];
      [super viewDidLoad];
  }
  </code></pre>