title: Declaring objects from one xib to another in Xcode?
body: <p>I have a project that has a switch from an xib separate from the main ViewController. I am trying to make it so that when you switch the UISwitch to OFF a button in the ViewController is hidden. I have tried to declare the AppDelegate in the xib's .m file but still no luck. My code is: </p>
  
  <pre><code>- (void)viewDidAppear:(BOOL)animated {
  
  AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
  </code></pre>
  
  <p>}</p>
  
  <p>What am I doing wrong? I am trying to do </p>
  
  <pre><code>if (switch.on) {
       myButton.hidden = YES;
     } else {
       myButton.hidden = NO;
  }
  </code></pre>
  
  <p>I have also done this in the .m file of the second xib (the one that does not have the main ViewController)</p>
  
  <pre><code>#import "AppDelegate.h"
  #import "ViewController.h"
  </code></pre>
  
  <p>But still NOTHING! So basically, I'm just trying to declare a button in one xib from another. THAT'S IT. PLEASE HELP Thanks!</p>