title: How to pass the NSString from One UIViewController to Another UIViewController?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/11272864/ios-passing-variable-to-view-controller">iOS - Passing variable to view controller</a>  </p>
  </blockquote>
  
  
  
  <p>I have two Viewcontrollers (ViewController1 and ViewController2) , And i want to pass a String value along with a IBAction from ViewController1 to ViewController2. I am trying to read the NSString (*check) value in ViewController2's ViewDidLoad method, but it's returning a null value. </p>
  
  <p>Help me out and Thanks in advance. </p>
  
  <pre><code>// ViewController1
  
  @interface ViewController1 : UIViewController {
  
          IBOutlet UIButton *btn1;
          IBOutlet UIButton *btn2;
          NSString *check;
      }
  #import "ViewController.h"
  
  -(IBAction)buttonClicked:(id)sender {
  
      check = [[NSString alloc] init];
  
      if (btn1.tag == 0) {
          check = @"foo";
          NSLog(@"%@",check);    
      }
      if (btn2.tag == 1) {
          check = @"bar";
          NSLog(@"%@",check);
      }
  } 
  </code></pre>
  
  <p>in my second view controller ,</p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  
  @class ViewController1;
  
  @interface ViewController2 : UIViewController {
  
      ViewController1 *viewCon;
  }
  
  @property(nonatomic,retain) ViewController *viewCon;
  
  //.m
  
  #import "ViewController2.h"
  #import "ViewController1.h"
  
  @synthesize viewCon,
  
   - (void)viewDidLoad
  {
      ViewController *myVC = [[ViewController alloc] init];
      NSLog(@"  Label  %@",myVC.check);
      [super viewDidLoad];
  }
  </code></pre>