Skip to content

Instantly share code, notes, and snippets.

@AppleBetas
Last active January 15, 2017 06:43
Show Gist options
  • Save AppleBetas/027d3e586b62aa41089b5db97a35283c to your computer and use it in GitHub Desktop.
Save AppleBetas/027d3e586b62aa41089b5db97a35283c to your computer and use it in GitHub Desktop.
UIViewController+QuickAlert.swift - A UIViewController extension to quickly show alerts
//
// 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