当我按下按钮4次时,模拟器崩溃了。 我第四次按下按钮时,我想回到第一个问题。
let Questions = ["Who’s Louis?", "Who’s Mark?", "Who’s Paul?"]
@IBAction func answerButtonTapped(sender: AnyObject){
var question = questionField.text
// display question
questionField.text = listOfQuestions[currentQuestionIndex]
if currentQuestionIndex <= listOfQuestions.count {
++currentQuestionIndex
//discussQuestion(answer)
answerBut.setTitle("ANSWER", forState: UIControlState.Normal)
} else {
(sender as UIButton).userInteractionEnabled = false
}
}