Created
June 13, 2020 12:55
-
-
Save cipolleschi/c4c0057e4b2cbe35adbfcbee1926ccaf 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
| func userTapDialog { | |
| // Create the alert | |
| let alertControl = UIAlertController( | |
| title: "Question!", | |
| message: "What's your favourite color?", | |
| preferredStyle: .alert | |
| ) | |
| // add the red action | |
| alertControl.addAction(UIAlertAction(title: "Red", style: .default, handler: { [weak self] _ in | |
| self?.localState.color = "Red" | |
| })) | |
| // add the blue action | |
| alertControl.addAction(UIAlertAction(title: "Blue", style: .default, handler: { [weak self] _ in | |
| self?.localState.color = "Blue" | |
| })) | |
| // present the view controller | |
| self.present(alertControl, animated: true, completion: nil) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment