Last active
January 24, 2018 03:25
-
-
Save kashfifahim/2455249da4710120f3e79d1bcf9c454a to your computer and use it in GitHub Desktop.
Notes on alerts
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
// first let's create a function for the alert | |
// remember to connect this code to a button on the storyboard. | |
@IBAction func showAlert() { | |
// We have to (1) set up the alert | |
// then (2) we have to set up the action to the alert (the button inside the alert) | |
let alert = UIAlertController(title: "Hello, World!", message: "This is my first alert!", prefferredStyle: .alert) | |
let action = UIAlertAction(title: "Awesome", style: .default, handler: nil) | |
// (3) Now we have to add the action to the alert | |
alert.addAction(action) | |
// (4) Now we program this alert's presentation | |
present(alert, animated: true, completion: nil) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment