Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
button function
@IBAction func showMessage(sender: UIButton) {
var enabled = false
let alertController = UIAlertController(title: "Alert", message: enabled ? "Hello World!" : "Nothing to see here...", preferredStyle: UIAlertController.Style.alert)
if enabled {
alertController.addAction(UIAlertAction(title: "Hello!", style: UIAlertAction.Style.default, handler: nil))
} else {
alertController.addAction(UIAlertAction(title: "Ok", style: UIAlertAction.Style.default, handler: nil))
}
present(alertController, animated: true, completion: nil)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment