title: Set Child View Controller Properties
body: <p>Ok, I know this has been asked before and I have tried many different methods to make this work but for some reason it won't. I am trying to save a string to a label's text property. The label is in a child view controller called <code>tableVC</code> within a container view and I am setting it from the parentViewController, <code>ViewController</code> in an IBAction when the value of a UIDatePicker, <code>datePicker</code> is changed. I have tried:</p>
  
  <pre><code>tableVC *tVC = [[tableVC alloc] init];
  tVC.timeLabel.text = [formatter stringFromDate:self.datePicker.date];
  </code></pre>
  
  <p>and have also tried making a property <code>@property (strong, nonatomic) tableVC *tVC;</code> then doing:</p>
  
  <pre><code>_tVC = [tableVC alloc] init];
  _tVC.timeLabel.text = [formatter stringFromDate:self.datePicker.date];
  </code></pre>
  
  <p>but that doesn't work either. BTW, I have <code>#import "tableVC"</code>. I don't want a complicated delegate or protocol way of doing it as I'm thinking I am just making a noob mistake. Also, I have confirmed that <code>[formatter stringFromDate:self.datePicker.date]</code> does return the proper, non nil, formatted, value from the datePicker, using <code>NSLog(@"%@", [formatter stringFromDate:self.datePicker.date]);</code>. </p>
  
  <p><strong>Edit</strong></p>
  
  <p>Here is a little more information along with the entire files. The table is a static table defined in Storyboard. I thought this could be the cause of the problem but even when I substituted out the <code>tableVC</code> for a subclassed <code>UIViewController</code> with only one label it did not work. I think the problem lies in how I set the child view controller properties. However, I do not have this problem when using the <code>prepareForSeque</code> method in other projects. I can set values for properties of the destination controller no problem but not values for properties of view controllers which are not the destination controller. I think these two problems coincide. All connections were made properly through Storyboard.</p>
  
  <p>ViewController.h</p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  
  @interface ViewController : UIViewController
  
  @end
  </code></pre>
  
  <p>ViewController.m</p>
  
  <pre><code>#import "ViewController.h"
  #import "tableVC.h"
  
  @interface ViewController ()
  
  @property (weak, nonatomic) IBOutlet UIView *containerView;
  @property (weak, nonatomic) IBOutlet UILabel *testLabel;
  @property (weak, nonatomic) IBOutlet UIDatePicker *datePicker;
  
  - (IBAction)changedDatePickerSelection:(id)sender;
  
  @end
  
  @implementation ViewController
  
  - (void)viewDidLoad
  {
      [super viewDidLoad];
  
      tableVC *tVC = [[tableVC alloc] init];
      [self addChildViewController:tVC];
      [tVC didMoveToParentViewController:self];
  
      NSLog(@"parent");
  }
  
  - (IBAction)changedDatePickerSelection:(id)sender
  {
      NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
      formatter.timeZone = [NSTimeZone defaultTimeZone];
      formatter.timeStyle = NSDateFormatterShortStyle;
      formatter.dateStyle = NSDateFormatterMediumStyle;
  
      tableVC *tVC = (tableVC *)self.childViewControllers.lastObject;
      tVC.timeLabel.text = [formatter stringFromDate:self.datePicker.date];
  
      _testLabel.text = [formatter stringFromDate:self.datePicker.date];
  
      NSLog(@"%@", [formatter stringFromDate:_datePicker.date]);
      NSLog(@"%@", tVC.timeLabel.text);
  }
  
  @end
  </code></pre>
  
  <p>tableVC.h</p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  
  @interface tableVC : UITableViewController
  
  @property (weak, nonatomic) IBOutlet UILabel *timeLabel;
  
  @end
  </code></pre>
  
  <p>tableVC.m</p>
  
  <pre><code>#import "tableVC.h"
  #import "ViewController.h"
  
  @interface tableVC ()
  
  @property (weak, nonatomic) IBOutlet UITextField *titleTextField;
  @property (weak, nonatomic) IBOutlet UISwitch *onOffSwitch;
  @property (weak, nonatomic) IBOutlet UIButton *saveButton;
  
  - (IBAction)saveAlarm;
  
  @end
  
  @implementation tableVC
  
  - (id)initWithStyle:(UITableViewStyle)style
  {
      self = [super initWithStyle:style];
      if (self) {
          // Custom initialization
      }
      return self;
  }
  
  - (void)viewDidLoad
  {
      [super viewDidLoad];
  
      NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
      formatter.timeZone = [NSTimeZone defaultTimeZone];
      formatter.timeStyle = NSDateFormatterShortStyle;
  
      _timeLabel.text = [formatter stringFromDate:[NSDate date]];
      NSLog(@"%@", _timeLabel.text);
  }
  
  - (BOOL)textFieldShouldReturn:(UITextField*)aTextField
  {
      [aTextField resignFirstResponder];
      return YES;
  }
  
  - (IBAction)saveAlarm
  {
      // do something
  }
  
  @end
  </code></pre>
  
  <p>Also, here are my two images to show how the <code>testLabel</code> from the <code>ViewController</code> is updated when the <code>datePicker</code>'s selection is changed, but how the <code>timeLabel</code> from the <code>tableVC</code> was not. The first image is before the change of selection and the second is after. For clarification, the <code>timeLabel</code> is the label on the right side of the third cell and the <code>testLabel</code> is the one directly above the <code>datePicker</code>.</p>
  
  <p><a href="http://cl.ly/image/2Q301v0d2m00" rel="nofollow">http://cl.ly/image/2Q301v0d2m00</a></p>
  
  <p><a href="http://cl.ly/image/0223183E1t2m" rel="nofollow">http://cl.ly/image/0223183E1t2m</a></p>
  
  <p>Thanks for any help.    </p>