simplify alert code
This commit is contained in:
parent
5ed3629c52
commit
edfd8c97a7
7 changed files with 21 additions and 40 deletions
|
|
@ -32,26 +32,17 @@ class PGPKeySettingTableViewController: UITableViewController {
|
|||
}
|
||||
|
||||
guard URL(string: pgpPublicKeyURLTextField.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 false
|
||||
}
|
||||
guard URL(string: pgpPrivateKeyURLTextField.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 false
|
||||
}
|
||||
|
||||
if URL(string: pgpPublicKeyURLTextField.text!)!.scheme! == "http" &&
|
||||
URL(string: pgpPrivateKeyURLTextField.text!)!.scheme! == "http" {
|
||||
let alertMessage = "HTTP connection is not supported."
|
||||
let alert = UIAlertController(title: "Cannot Save Settings", 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 Settings", message: "HTTP connection is not supported.", controller: self, completion: nil)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue