//
//  UIAlertController+Show.swift
//  UIAlertController+Show
//
//  Created by Erik Ackermann on 1/20/16.
//
//

import Foundation
import UIKit
import ObjectiveC

private var alertWindowAssociationKey: UInt8 = 0

extension UIAlertController {

    var alertWindow: UIWindow? {
        get {
            return objc_getAssociatedObject(self, &alertWindowAssociationKey) as? UIWindow
        }
        set(newValue) {
            objc_setAssociatedObject(self, &alertWindowAssociationKey, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
        }
    }

    @objc public func show() {
        show(animated: true)
    }

    @objc public func show(animated: Bool) {
        self.alertWindow = UIWindow(frame: UIScreen.main.bounds)
        self.alertWindow?.rootViewController = UIViewController()
        self.alertWindow?.windowLevel = UIWindowLevelAlert + 1
        self.alertWindow?.makeKeyAndVisible()
        self.alertWindow?.rootViewController?.present(self, animated: animated, completion: nil)
    }

    override open func viewDidDisappear(_ animated: Bool) {
        super.viewDidDisappear(animated)

        self.alertWindow?.isHidden = true
        self.alertWindow = nil
    }
}

//
//  UIAlertController+Show.swift
//  UIAlertController+Show
//
//  Created by Erik Ackermann on 1/20/16.
//
//

import Foundation
import UIKit
import ObjectiveC

private var alertWindowAssociationKey: UInt8 = 0

extension UIAlertController {

    var alertWindow: UIWindow? {
        get {
            return objc_getAssociatedObject(self, &alertWindowAssociationKey) as? UIWindow
        }
        set(newValue) {
            objc_setAssociatedObject(self, &alertWindowAssociationKey, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
        }
    }

    @objc public func show() {
        show(true)
    }

    @objc public func show(animated: Bool) {
        self.alertWindow = UIWindow(frame: UIScreen.mainScreen().bounds)
        self.alertWindow?.rootViewController = UIViewController()
        self.alertWindow?.windowLevel = UIWindowLevelAlert + 1
        self.alertWindow?.makeKeyAndVisible()
        self.alertWindow?.rootViewController?.presentViewController(self, animated: animated, completion: nil)
    }

    override public func viewDidDisappear(animated: Bool) {
        super.viewDidDisappear(animated)

        self.alertWindow?.hidden = true
        self.alertWindow = nil
    }
}

--- 
+++ 
@@ -24,21 +24,21 @@
     }
 
     @objc public func show() {
-        show(true)
+        show(animated: true)
     }
 
     @objc public func show(animated: Bool) {
-        self.alertWindow = UIWindow(frame: UIScreen.mainScreen().bounds)
+        self.alertWindow = UIWindow(frame: UIScreen.main.bounds)
         self.alertWindow?.rootViewController = UIViewController()
         self.alertWindow?.windowLevel = UIWindowLevelAlert + 1
         self.alertWindow?.makeKeyAndVisible()
-        self.alertWindow?.rootViewController?.presentViewController(self, animated: animated, completion: nil)
+        self.alertWindow?.rootViewController?.present(self, animated: animated, completion: nil)
     }
 
-    override public func viewDidDisappear(animated: Bool) {
+    override open func viewDidDisappear(_ animated: Bool) {
         super.viewDidDisappear(animated)
 
-        self.alertWindow?.hidden = true
+        self.alertWindow?.isHidden = true
         self.alertWindow = nil
     }
 }
Update for Swift 3.0 syntax.
