我正在写一个简单的测验应用程序。虽然UIViewController是在按钮操作中实现的,但它不会被触发。
@IBAction func answerPressed(_ sender: AnyObject) {
nextQuestion()
failingMethod()
}
func nextQuestion() {
questionIndex+=1
if(questionIndex >= allQuestions.list.count){
let alert = UIAlertController(title: "Awesome", message: "You've finished all the questions, do you want to start over?", preferredStyle: .alert)
let restartAction = UIAlertAction(title: "Restart", style: .default, handler: { UIAlertAction in
self.startOver()
})
alert.addAction(restartAction)
present(alert, animated: true, completion: nil)
}
}