Skip to content

Instantly share code, notes, and snippets.

@cipolleschi
Created June 13, 2020 12:55
Show Gist options
  • Select an option

  • Save cipolleschi/c4c0057e4b2cbe35adbfcbee1926ccaf to your computer and use it in GitHub Desktop.

Select an option

Save cipolleschi/c4c0057e4b2cbe35adbfcbee1926ccaf to your computer and use it in GitHub Desktop.
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