Skip to content

Instantly share code, notes, and snippets.

@YuiChiLo
Created September 12, 2016 12:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YuiChiLo/0455d53d4c303f887fc583002be441e4 to your computer and use it in GitHub Desktop.
Save YuiChiLo/0455d53d4c303f887fc583002be441e4 to your computer and use it in GitHub Desktop.
import UIKit
extension UIViewController {
func getForegroundAlertController() -> UIAlertController? {
var viewController = UIApplication.sharedApplication().keyWindow?.rootViewController
while let controller = viewController?.presentedViewController {
if controller is UIAlertController {
viewController = controller
break
}
}
guard let alert = viewController as? UIAlertController else {
return nil
}
return alert
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment