无法识别的选择器以简单代码发送到实例

时间:2017-07-31 04:03:34

标签: ios swift

我可以问下面的问题吗?

  

[Quiz.ViewController showNextQuesttionWithSender:]:无法识别   选择器发送到实例0x7ff0b150c720

发生在下面的代码中。我不明白什么是吝啬。

class ViewController: UIViewController { 

    @IBOutlet var questionLabel: UILabel!
    @IBOutlet var answerLabel: UILabel!

    let questions: [String] = ["birth daut?", "name?", "birth son?"]
    let answers: [String] = ["12wol4il", "yuha", "54"]
    var currentQuestionIndex: Int = 0

    @IBAction func showNextQuestion(sender: AnyObject) {
        currentQuestionIndex+=1
        if currentQuestionIndex == questions.count
        {
            currentQuestionIndex = 0
        }

        let question: String = questions[currentQuestionIndex]
        questionLabel.text = question
        answerLabel.text = "???"
    }

    @IBAction func showAnswer(sender: AnyObject) {
        let answer: String = answers[currentQuestionIndex]
        answerLabel.text = answer
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        questionLabel.text = questions[currentQuestionIndex]
    }
}

1 个答案:

答案 0 :(得分:1)

你的故事板中只有一个拼写错误。

showNextQuesttion应为showNextQuestion