simplify alert code

This commit is contained in:
Bob Sun 2017-02-16 00:54:42 +08:00
parent 5ed3629c52
commit edfd8c97a7
No known key found for this signature in database
GPG key ID: 1F86BA2052FED3B4
7 changed files with 21 additions and 40 deletions

View file

@ -33,17 +33,11 @@ class SSHKeySettingTableViewController: UITableViewController {
func doneButtonTapped(_ sender: UIButton) {
guard URL(string: publicKeyURLTextField.text!) != nil else {
let alertMessage = "Please set Public Key URL first."
let alert = UIAlertController(title: "Cannot Save", message: alertMessage, preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: nil))
self.present(alert, animated: true, completion: nil)
Utils.alert(title: "Cannot Save", message: "Please set Public Key URL first.", controller: self, completion: nil)
return
}
guard URL(string: privateKeyURLTextField.text!) != nil else {
let alertMessage = "Please set Private Key URL first."
let alert = UIAlertController(title: "Cannot Save", message: alertMessage, preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: nil))
self.present(alert, animated: true, completion: nil)
Utils.alert(title: "Cannot Save", message: "Please set Private Key URL first.", controller: self, completion: nil)
return
}