Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swift 如何修复警报_Swift_Xcode - Fatal编程技术网

Swift 如何修复警报

Swift 如何修复警报,swift,xcode,Swift,Xcode,我编写了一个输出警报的函数,但它不起作用 下面是函数: if titleTextField.text.isEmpty == false { if let result = DataManager.shared.quizController.joinQuiz(id: titleTextField.text) { switch result { case .badCode :

我编写了一个输出警报的函数,但它不起作用

下面是函数:

if titleTextField.text.isEmpty == false {
            if let result = DataManager.shared.quizController.joinQuiz(id: titleTextField.text) {
                switch result {
                case .badCode :
                    self.showErrorAlert(message: "Bad code")
                case .joined:
                    self.showErrorAlert(message: "You are alredy joined")
                case .notJoined:
                    navigationController?.popToRootViewController(animated: true)

我希望这会输出一些警报,但是我没有得到任何输出。

以下是显示警报的简单方法

if titleTextField.text.isEmpty == false {
            if let result = DataManager.shared.quizController.joinQuiz(id: titleTextField.text) {
                switch result {
                case .badCode :
                    self.showErrorAlert(message: "Bad code")
                case .joined:
                    self.showErrorAlert(message: "You are alredy joined")
                case .notJoined:
                    navigationController?.popToRootViewController(animated: true)
                }
       }
//function for showing alert message

    func showErrorAlert(_ with message: String){
        let alert = UIAlertController(title: "", message: message, preferredStyle: .alert)
        let okAction = UIAlertAction(title: "ok", style: .default, handler: nil)
        alert.addAction(okAction)
        self.present(alert, animated: true, completion: nil)
    }

嘿,欢迎来到StackOverflow。为了更好地理解您的问题,我们需要查看更多代码。首先,您要知道,您的警报(消息:)是做什么的?它是如何实现的?