Last active
January 15, 2017 06:43
-
-
Save AppleBetas/027d3e586b62aa41089b5db97a35283c to your computer and use it in GitHub Desktop.
UIViewController+QuickAlert.swift - A UIViewController extension to quickly show alerts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// UIViewController+QuickAlert.swift | |
// | |
// Created by AppleBetas on 2016-09-11. | |
// Copyright © 2016 AppleBetas. All rights reserved. | |
// | |
import UIKit | |
extension UIViewController { | |
func showAlert(title: String? = nil, message: String? = nil, handler: (() -> Void)? = nil) { | |
let alert = UIAlertController(title: title, message: message, preferredStyle: .alert) | |
alert.addAction(UIAlertAction(title: "OK", style: .cancel) { _ in | |
handler?() | |
}) | |
present(alert, animated: true, completion: nil) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment