title: How to access main window from view controllers in Objective-C?
body: <p>I create a custom view controller named <code>HomeViewController</code> which inherits from <code>UIViewController</code>. In main application delegate, I show it by calling <code>[window addSubview:homeViewController.view]</code> inside function <code>applicationDidFinishLaunching</code>. Yeah, everything works fine.</p>
  
  <p>Now I add a button into the <code>HomeViewController</code> xib file. When I click on it, I want the <code>window</code> to remove the current view and add another <code>navigationController</code> instead. I make a function inside <code>HomeViewController.m</code> and link to the button but I don't know how to access the property <code>window</code> from there. <code>window</code> is a local variable inside the main app delegate and button click handler is inside <code>HomeViewController</code>. I'm thinking of doing the similar thing as above which is to add <code>navigationController.view</code> as subview of <code>window</code>.</p>
  
  <p>Sorry! I'm very new to this iphone app development. I don't really get the big picture of how the application flow should be. Perhaps something's wrong with the structure of my project?</p>