Skip to content

Instantly share code, notes, and snippets.

@jasonhilimire
Last active December 11, 2017 23:39
Show Gist options
  • Select an option

  • Save jasonhilimire/c0dff5e1fcef4dabc7ba1b0ab3d19331 to your computer and use it in GitHub Desktop.

Select an option

Save jasonhilimire/c0dff5e1fcef4dabc7ba1b0ab3d19331 to your computer and use it in GitHub Desktop.
[UIAlertController] How to show An Alert Controller #swift
let alertController = UIAlertController(title: "Warning!", message: "This will DELETE all your Shot Cycles data!! This cannot be undone", preferredStyle: .alert)
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel) { action in
print("Cancel button pressed")
}
alertController.addAction(cancelAction)
// maybe some stuff
let deleteAction = UIAlertAction(title: "Delete", style: .destructive) { action in
// some stuff
// probably need this if using in a tableView self.tableView.reloadData()
print("Delete button pressed")
}
alertController.addAction(deleteAction)
self.present(alertController, animated: true) {
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment