This compiles and runs but does not do anything. Have looked at other solutions on web but so far all are out of date.
@IBAction func rate(_ sender: AnyObject) {
let alert = UIAlertController(title: “New Rating”,
message: “Rate this bow tie”,
preferredStyle: .alert)
alert.addTextField { (textField) in
textField.keyboardType = .decimalPad
}
let cancelAction = UIAlertAction(title: “Cancel”,
style: .default)
let saveAction = UIAlertAction(title: “Save”,
style: .default) {
[unowned self] action in
guard let textField = alert.textFields?.first else {
return
}
self.update(rating: textField.text)
}
alert.addAction(cancelAction)
alert.addAction(saveAction)
present(alert, animated: true)
}