title: How to "preload" view controller without actually pushing it?
body: <p><strong>Background:</strong>
  I've got a free app that is ad-supported.  The basic idea is that when the app is launched, ad content (HTML) is downloaded from the server in the background, and only if the download was successful, then the content is being shown.</p>
  
  <p><strong>Previous solution:</strong>
  I have implemented this successfully in a universal app.  Originally, I loaded a <code>NSData</code> variable with an URL, and if it was successful, then I presented a modal view which contained an <code>UIWebView</code> (relevant code is in <a href="https://stackoverflow.com/questions/5123266/uiwebview-acts-differnetly-in-app-store-version-than-dev-version">another question</a>). The problem is that the external assets (images) don't get loaded in the original <code>NSData</code> request, so in a stroke of genius I thought of another way:</p>
  
  <p><strong>New solution:</strong>
  The new way, and this is what I want help with, is that I'm instantiating the modal view controller (without displaying it yet), and having the web view begin loading the URL directly.  When the <code>webViewDidFinishLoad</code> method is called, I fire a notification back to the parent which then performs the <code>presentModalViewController</code>.</p>
  
  <p>Here are the methods which instantiate the view controller and present it modally:</p>
  
  <pre><code>- (void)launchAd
  {
      if ([ServerCheck serverReachable:@"openx.freewave-wifi.com" hideAlert:YES])
      {
          [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(presentAdModal) name:@"AdLoaded" object:nil];
  
          AdViewController *adView = [[AdViewController alloc] initWithNibName:nil bundle:nil];
          [[adView view] awakeFromNib]; //THIS LINE IS WHAT THIS QUESTION IS ABOUT
  
          navController = [[UINavigationController alloc] initWithRootViewController:adView];
          [adView release], adView = nil;
  
          [navController setModalPresentationStyle:UIModalPresentationFormSheet];
          [navController setModalTransitionStyle:UIModalTransitionStyleCoverVertical];
          [[navController navigationBar] setTintColor:[UIColor colorWithRed:0.94 green:0.00 blue:0.32 alpha:1.00]];
      }
      else
          LogError(@"Not presenting ad.");
  }
  
  - (void)presentAdModal
  {
      LogInfo(@"Presenting advertisement modal.");
  
      [[NSNotificationCenter defaultCenter] removeObserver:self name:@"AdLoaded" object:nil];
  
      [tabBarController presentModalViewController:navController animated:YES];
  
      [navController release];
  }
  </code></pre>
  
  <p>And in the AdView controller:</p>
  
  <pre><code>- (void)webViewDidFinishLoad:(UIWebView *)theWebView
  {
      LogInfo(@"Ad content did load; we can show it.");
  
      [timeout invalidate], timeout = nil;
  
      [self setTitle:@"From Our Sponsor"];
  
      [[NSNotificationCenter defaultCenter] postNotificationName:@"AdLoaded" object:nil];
  }
  </code></pre>
  
  <p>Now what's above <strong>does work</strong>.  However, it took a long time for me to figure out how to cause the view controller delegate methods in the <code>AdView</code> controller to fire <em>before</em> calling <code>presentModalViewController</code>.  I did this by adding <code>[[adView view] awakeFromNib];</code>, but I know this isn't the right way to make this happen.</p>
  
  <p>So, everything above does work beautifully, effectively having the view controller and its <code>UIWebView</code> "preload" before displaying it.  I just want to know what I should be doing instead of <code>[[adView view] awakeFromNib];</code> -- I want to do it the right way.</p>
  
  <p>Or is this right?  I guess some folks would say "If it works, then it's right", but I know this isn't true.</p>