Last active
September 27, 2018 18:44
-
-
Save davut/d83ef51ad316d6a17f396b94d5f00f21 to your computer and use it in GitHub Desktop.
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
extension UIViewController { | |
func showAlert(withTitle title: String, message: String, actionTitle: String = "OK") { | |
let alertController = UIAlertController(title: title, message: message, preferredStyle: .alert) | |
let action = UIAlertAction(title: actionTitle, style: .default, handler: nil) | |
alertController.addAction(action) | |
present(alertController, animated: true, completion: nil) | |
} | |
func showHeyAlert() { | |
// Customizable actionTitle | |
showAlert(withTitle: "Hey", message: "HeyHey", actionTitle: "Hey Hey Yo") | |
} | |
func showHiAlertWithOK() { | |
// actionTitle is "OK" (which is default) | |
showAlert(withTitle: "Hi", message: "HiHi") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment