Skip to content

Instantly share code, notes, and snippets.

@ITechRoof
Last active May 21, 2018 16:05
Show Gist options
  • Save ITechRoof/c723ada9c35889aa292b6830dadf658c to your computer and use it in GitHub Desktop.
Save ITechRoof/c723ada9c35889aa292b6830dadf658c to your computer and use it in GitHub Desktop.
let alertController = UIAlertController.init(title: "Destination", message: nil, preferredStyle: .actionSheet)
for dest in destinationArray {
let action = UIAlertAction.init(title: dest.key, style: .default) {[weak self] (action) in
self?.selectedDestinationLabel.text = "You have selected " + dest.key
if let userDefault = UserDefaults.init(suiteName: "group.itr.todayWidget")
{
userDefault.setValue(dest.value, forKey: "Destination")
userDefault.synchronize()
}
}
alertController.addAction(action)
}
let cancelAction = UIAlertAction.init(title: "Cancel", style: .destructive, handler: nil)
alertController.addAction(cancelAction)
self.present(alertController, animated: true, completion: nil)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment