Skip to content

Instantly share code, notes, and snippets.

@bittz
Last active August 31, 2016 08:17
Show Gist options
  • Save bittz/fa09c9602124cde84f3787cf027cce89 to your computer and use it in GitHub Desktop.
Save bittz/fa09c9602124cde84f3787cf027cce89 to your computer and use it in GitHub Desktop.
Present basic alert with UIViewController.
import UIKit
extension UIViewController {
func presentAlert(message: String) {
if presentedViewController == nil {
let alertController = UIAlertController(title: nil, message: message, preferredStyle: .Alert)
let alertAction = UIAlertAction(title: "OK", style: .Default, handler: nil)
alertController.addAction(alertAction)
presentViewController(alertController, animated: true, completion: nil)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment