アラートを表示するメソッド
//アラート func displayAleart() { let alert: UIAlertController = UIAlertController(title: "アラート表示", message: "保存してもいいですか?", preferredStyle: UIAlertController.Style.alert) let defaultAction: UIAlertAction = UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler:{ (action: UIAlertAction!) -> Void in print("OK") }) let cancelAction: UIAlertAction = UIAlertAction(title: "キャンセル", style: UIAlertAction.Style.cancel, handler:{ (action: UIAlertAction!) -> Void in print("Cancel") }) alert.addAction(cancelAction) alert.addAction(defaultAction) present(alert, animated: true, completion: nil) }