以下のソースコードでタイトルのエラーが出てしまいます。
エラーが出る場所は override func viewDidLoad()の中です。
接続を繋ぎ直したりしてもエラーが出てしまいます。
swift
1import UIKit 2import AudioToolbox 3 4class answerView: UIViewController { 5 var questionData: QuestionData! 6 7 @IBOutlet weak var QuestionLabel: UILabel! 8 9 @IBOutlet weak var questionTextView: UITextView! 10 @IBOutlet weak var answerButton: UIButton! 11 @IBOutlet weak var answerButton2: UIButton! 12 @IBOutlet weak var inCorrectView: UIImageView! 13 @IBOutlet weak var correctView: UIImageView! 14 15 override func viewDidLoad() { 16 super.viewDidLoad() 17 QuestionLabel.text = "Q. (questionData.questionNo)" 18 questionTextView.text = questionData.question 19 answerButton.setTitle(questionData.answer, for: UIControl.State.normal) 20 answerButton2.setTitle(questionData.answer2, for: UIControl.State.normal) 21 } 22 23 @IBAction func tapAnswerButton(_ sender: Any) { 24 questionData.userSelect = 1 25 goNextQuestionWithAnimation() 26 } 27 28 @IBAction func tapAnswerButton2(_ sender: Any) { 29 questionData.userSelect = 1 30 goNextQuestionWithAnimation() 31 } 32 33 34 35// 次のアニメーションへ 36 func goNextQuestionWithAnimation() { 37 if questionData.correct() { 38 goNextQuestionCorrect() 39 } else { 40 goNextQuestionInCorrect() 41 } 42 } 43 44 func goNextQuestionCorrect() { 45 AudioServicesPlayAlertSound(1025) 46 47 UIView.animate(withDuration: 2.0, animations: { 48 self.correctView.alpha = 1.0 49 }) { (Bool) in 50 self.goNextQuestion() 51 } 52 } 53 54 func goNextQuestionInCorrect() { 55 AudioServicesPlayAlertSound(1026) 56 57 UIView.animate(withDuration: 2.0,animations: { 58 self.inCorrectView.alpha = 1.0 59 }) {(Bool) in 60 self.goNextQuestion() 61 } 62 } 63 64 func goNextQuestion() { 65 guard let nextQuestion = QuestionDataManager.sharedInstance.nextQuestion() else { 66 67 if let resultViewController = storyboard?.instantiateViewController(withIdentifier: "result") as? ResultView { 68 present(resultViewController, animated: true, completion: nil) 69 } 70 return 71 } 72 73 if let nextQuestionViewController = 74 storyboard?.instantiateViewController(withIdentifier: "question") as? answerView { 75 nextQuestionViewController.questionData = nextQuestion 76 77 present(nextQuestionViewController, animated: true, 78 completion: nil) 79 } 80 } 81}