override func shouldPerformSegue(withIdentifier identifier: String, sender: Any?) -> Bool { if identifier == "showResult" { guard self.sales.text != "" else{ let alertController = UIAlertController(title: "Error", message: "Please enter your name", preferredStyle: .alert) let defaultAction = UIAlertAction(title:"OK", style: .default, handler: nil) alertController.addAction(defaultAction) self.present(alertController, animated: true, completion: nil) return false } return true } return true }
初期
text fieldがnilの時