show alert if key url is empty

This commit is contained in:
Bob Sun 2017-02-15 22:34:16 +08:00
parent a62d50abb0
commit 545a5b11bb
No known key found for this signature in database
GPG key ID: 1F86BA2052FED3B4
2 changed files with 34 additions and 0 deletions

View file

@ -30,6 +30,22 @@ class PGPKeySettingTableViewController: UITableViewController {
guard pgpPrivateKeyURLTextField.text != nil else {
return false
}
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)
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)
return false
}
if URL(string: pgpPublicKeyURLTextField.text!)!.scheme! == "http" &&
URL(string: pgpPrivateKeyURLTextField.text!)!.scheme! == "http" {
let alertMessage = "HTTP connection is not supported."