title: How to reference an AppDelegate instance variable from the custom controller action?
body: <p>I want to be able (as a learning exercise for controllers) have a button on the initial view I setup, then if you click the button an action occurs which swaps out the view from view 1 to view 2.  I'm not sure how you this?  See the section in the code below where I would like to put in the code that does this.</p>
  
  <p>Can any post the code I would need?  (i.e. which would cover how to reference a variable I established in the AppDelegate).  Let me know if this practice exercise I've given myself is flawed somewhere.  Thanks.</p>
  
  <p>AppDelegate *.h</p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  @class gregsController;
  @class Gregs2ndController;  
  
  @interface windowsBasedAppDelegate : NSObject &lt;UIApplicationDelegate&gt; {
      UIWindow *window;
      gregsController *viewController;
      Gregs2ndController *view2Controller;
  
  }
  
  @property (nonatomic, retain) IBOutlet UIWindow *window;
  @property (nonatomic, retain) IBOutlet gregsController *viewController;
  @property (nonatomic, retain) IBOutlet Gregs2ndController *view2Controller;
  
  @end
  </code></pre>
  
  <p>AppDelegate *.m</p>
  
  <pre><code>#import "windowsBasedAppDelegate.h"
  #import "gregsController.h"
  #import "Gregs2ndController.h"
  
  @implementation windowsBasedAppDelegate
  
  @synthesize window;
  @synthesize viewController;
  @synthesize view2Controller;
  
  - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
  
      // Override point for customization after application launch.
      NSLog(@"windowsBasedAppDelegate - didFinishLaunchingWithOptions");
  
      //[self.window addSubview:viewController.view];
      [self.window addSubview:view2Controller.view];
      [self.window makeKeyAndVisible];
  
      return YES;
  }
  </code></pre>
  
  <p>Custom Controller *.m</p>
  
  <pre><code>#import "gregsController.h"
  @implementation gregsController
  - (IBAction)logSomething {
      NSLog(@"About to switch views");
      [self.view removeFromSuperview];
  
          // *** HOW DO I REFERENCE view2Controller AND PUT THIS AS THE VIEW  ???? ****
  
      NSLog(@"Finished switching views");
  }
  </code></pre>