How can I capture a return key press and perform an action for a text field inside an alert? Here's the code for the alert:
var alert = UIAlertController(title: "Add Country", message: "Add a country to the Speaker's List", preferredStyle: .Alert)
let saveAction = UIAlertAction(title: "Save", style: .Default) {
(action: UIAlertAction!) -> Void in
let textField = alert.textFields![0] as! UITextField
self.countries.append(textField.text)
self.speakersListTableView.reloadData()
}
let cancelAction = UIAlertAction(title: "Cancel", style: .Default) {
(action: UIAlertAction!) -> Void in
}
alert.addTextFieldWithConfigurationHandler {
(textField: UITextField!) -> Void in
}
alert.addAction(saveAction)
alert.addAction(cancelAction)