Skip to content

Instantly share code, notes, and snippets.

@rajohns08
Last active July 8, 2016 00:31
Show Gist options
  • Save rajohns08/de6a5c66ed160bb2caec to your computer and use it in GitHub Desktop.
Save rajohns08/de6a5c66ed160bb2caec to your computer and use it in GitHub Desktop.
iOS / Swift - Helper class for showing a simple dialog
import UIKit
class OkAlert {
class func show(inViewController viewController: UIViewController, title: String, message: String) {
let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "Ok", style: UIAlertActionStyle.Default, handler: nil))
viewController.presentViewController(alert, animated: true, completion: nil)
}
class func showUnknownErrorAlert(inViewController viewController: UIViewController) {
OkAlert.show(inViewController: viewController, title: "Unknown Error", message: "An Unknown error occurred")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment