I was trying the same but does not work because after change of viewcontroller still returned the initial viewcontroller and throw the error whose view is not in the window hierarchy!. Finally, I found the solution to this problem:
UIApplication.sharedApplication().keyWindow?.rootViewController?.presentViewController(alertController, animated: true, completion: nil)
But I have to force view controllers to update de keyWindow with this:
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
UIApplication.sharedApplication().keyWindow!.rootViewController = self
UIApplication.sharedApplication().keyWindow!.makeKeyAndVisible()
}