AppDelegate "unexpected nil window' error
<p><strong>EDIT:</strong> 
People downvoting this because I used sleep, this is why I used it:</p>

<p><a href="https://stackoverflow.com/questions/9451556/making-the-launch-image-display-longer-xcode">Making the launch image display longer xcode</a></p>

<p>The window size is small. If you don't want to answer, don't downvote it. 
I just want to get rid of this error.</p>

<blockquote>
  <p>unexpected nil window in _UIApplicationHandleEventFromQueueEvent,
  _windowServerHitTestWindow: UIClassicWindow: ; frame = (0 0; 320 568); userInteractionEnabled = NO; gestureRecognizers = NSArray: > ; layer =
  UIWindowLayer: >></p>
</blockquote>

<hr>

<p>I have an iOS app which runs on both iPad and iPhone in landscape mode. It runs fine on the ipad simulators but on the iphone 5s and iphone 6s (which I have tested so far), I get this error:</p>

<blockquote>
  <p>unexpected nil window in _UIApplicationHandleEventFromQueueEvent,
  _windowServerHitTestWindow: UIClassicWindow: ; frame = (0 0; 320 568); userInteractionEnabled = NO; gestureRecognizers = NSArray: > ;  layer =
  UIWindowLayer: >></p>
</blockquote>

<p>This is the AppDelegate code.. I don't have any problem on ipad. </p>

<pre><code>- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

//   [NSThread sleepForTimeInterval:3];

    [application setStatusBarHidden:YES];
    self.window = [UIWindow new];       

    if([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) {

        self-&gt;_loginViewController = [[LoginViewController alloc] initWithNibName:@"somename~ipad" bundle:nil];

    } else if([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone) {

        self-&gt;_loginViewController = [[LoginViewController alloc] initWithNibName:@"somename~iphone" bundle:nil];
    }

    [[NSUserDefaults standardUserDefaults] setValue:@(NO) forKey:@"_UIConstraintBasedLayoutLogUnsatisfiable"];

    self.window.rootViewController = nil;
    self.window.rootViewController = self-&gt;_loginViewController;

    [[UINavigationBar appearance] setBarTintColor:[UIColor blackColor]];
    [[UINavigationBar appearance] setTranslucent:NO];

    [self.window makeKeyAndVisible];
    [self.window setFrame:[[UIScreen mainScreen] bounds]];
    return YES;
}
</code></pre>