In Objective-C in the viewDidLoad method of a UIViewController I do this to get the keyWindow reference in my iOS app:
UIWindow * keyWindow = [[UIApplication sharedApplication] keyWindow];
So, I am porting this view controller into Swift and I do this one the viewDidLoad call:
let window = UIApplication.sharedApplication().keyWindow
I am trying to understand why the window is nil. When I put a breakpoint right after that line I then inspect window in the console and I get this:
(lldb) po window
nil
How can I get window to be a valid reference to the keyWindow of my application in swift?