title: How do I access my Application Delegate's window accessor method from another object?
body: <p>As mentioned before - I'm an Objective-C newbie of the first order but having read 4 physical books on the subject and a bucket-load of ebooks and documentation I still can't find what I'm looking for.</p>
  
  <p>I have a top-level content view controller that wants to configure its view property from the physical dimensions of the window property of the application delegate. This is something that several people have already asked questions on. (<code>[UIScreen mainScreen]</code> doesn't cut it for reasons already aired many times before on this forum). Therefore, the logical approach would be for the content view controller to read the frame of the application delegate's window. Now, the only answer I've found that comes close to this is to use <code>[[[UIApplication sharedApplication] window] frame]</code> - however, this only works once the window property has been made keyAndVisible. The content view controller needs to read the app delegate's window property <em>before</em> it gets to makeKeyAndVisible. The code goes in this order....</p>
  
  <p>App Delegate:</p>
  
  <pre><code>- (BOOL) application: (UIApplication *) application didFinishLaunchingWithOptions: (NSDictionary *) launchOptions {
  // This next line is a test window frame for R&amp;D purposes....
      [self setWindow: [[UIWindow alloc] initWithFrame: CGRectMake(0.0f, 20.0f, 320.0f, 320.0f)]];
  
      if ([self window]) {
          contentViewController = [[ContentViewControl alloc] initWithNibName: nil bundle: nil]; // Content view controller instantiated here
  
          if (contentViewController) {
              [[self window] addSubview: [contentViewController view]];
              [[self window] layoutSubviews];
              [[self window] makeKeyAndVisible];  // Window made key and visible here
              return YES;
          }
      }
  
      return NO;
  }
  </code></pre>
  
  <p>In my content view controller's initWithNibName: nil bundle: nil method I have the following test code...</p>
  
  <pre><code>- (id) initWithNibName: (NSString *) nibNameOrNil bundle: (NSBundle *) nibBundleOrNil {
      self = [super initWithNibName: nibNameOrNil bundle: nibBundleOrNil];
  
      if (self) {
          NSLog(@"%@", NSStringFromCGRect([[[UIApplication sharedApplication] keyWindow] frame]));
          // This does not work.
      }
  
      return self;
  }
  </code></pre>
  
  <p>This does not work due to the fact that App Delegate's window is not yet key and visible.
  So, my question is thus; What is the name of my App Delegate Class' instance? I know the App Delegate's <em>Class</em> name defaults to <code>myApplicationNameAppDelegate</code> but I'm after the <em>instance</em> name. I want to replace the call to <code>[[UIApplication sharedApplication] keyWindow]</code> by something like;</p>
  
  <pre><code>[myAppDelegatesInstanceName window].
  </code></pre>
  
  <p>Expanding this a little, how does one access methods in other target objects that are not scope descendants of the object doing the querying?</p>
  
  <p>Like I said, I'm a total noob to all of this and this is probably another dumb noobie question but it's one that nobody yet appears to have answered in a simple way.</p>
  
  <p>(Procedurally - my home turf - there are a plethora of ways to get the window stuff down into other levels of scope ranging from making the window globally accessible to the whole program suite to passing it down as a specific parameter through the various function hierarchies - but this Objective stuff seems to depart from established, procedural practice).</p>
  
  <p>If anyone can help, I'd be really grateful. This stuff is definitely not intuitive!
  V.V.</p>