I have only one window and I tried
UIWindow* mWindow = [[UIApplication sharedApplication] keyWindow];
but this returned nil.
I also
If your main window is an outlet of your AppDelegate (which should be the case), you may simply use
MyAppDelegate* myDelegate = (((MyAppDelegate*) [UIApplication sharedApplication].delegate)); [myDelegate.window ...]