Created
December 10, 2015 10:27
-
-
Save Jamonek/b01938e556f4ab4a6acf to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import UIKit | |
extension UIViewController { | |
func alert(title: String = "", message: String, actionTitle:String = "OK") { | |
let alertController = UIAlertController(title: title, message: message, preferredStyle: .Alert) | |
let OKAction = UIAlertAction(title: actionTitle, style: .Default, handler: nil) | |
alertController.addAction(OKAction) | |
self.presentViewController(alertController, animated: true, completion: nil) | |
} | |
} | |
// Example Usage | |
class TestVC: UIViewController { | |
override func viewDidAppear(animated: Bool) { | |
super.viewDidAppear(animated) | |
self.alert("Hello", message: "This is a sample alert controller", actionTitle: "Dismiss") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment