Swift 测验应用程序出错

Swift 测验应用程序出错,swift,syntax-error,uilabel,Swift,Syntax Error,Uilabel,嗨,我正在尝试创建一个简单的测验应用程序,但是我遇到了一个错误,它没有在ui标签中显示或增加问题,而是打印答案。我知道我很接近,只是找不到问题所在。如果你能帮我,我将非常感激。我知道这可能是个愚蠢的错误 import UIKit struct Quiz{ var question: String! var options: [String]! var answer: Int! } class QuizViewController: UIViewController

嗨,我正在尝试创建一个简单的测验应用程序,但是我遇到了一个错误,它没有在ui标签中显示或增加问题,而是打印答案。我知道我很接近,只是找不到问题所在。如果你能帮我,我将非常感激。我知道这可能是个愚蠢的错误

import UIKit

struct Quiz{
    var question: String!
    var options: [String]!
    var answer: Int!
}


class QuizViewController: UIViewController {

    @IBOutlet weak var QuestionLabel: UILabel!

    @IBOutlet var Options: [UIButton]!

    var questions = [Quiz]()
    var qNumber = Int()
    var answerNumber = Int()

    override func viewDidLoad() {
        super.viewDidLoad()

        questions = [Quiz(question: "What is your name?", options: ["AJ","Sami","Daniel","Sazzad"], answer: 1),
                     Quiz(question: "What is your colour?", options: ["red","green","blue","orange"], answer: 2),
                     Quiz(question: "What is your pets name?", options: ["Kitty","Marley","Button","Snoopy"], answer: 0),
                     Quiz(question: "What is your flat number?", options: ["204","205","208","209"], answer: 3)]
        selectQuestion()

        // Do any additional setup after loading the view.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    func selectQuestion(){

        if questions.count<0{
            qNumber = 0
            QuestionLabel.text = questions[qNumber].question

            answerNumber = questions[qNumber].answer

            for i in 0..<Options.count{

                Options[i].setTitle(questions[qNumber].options[i], for: UIControlState.normal)
            }

            questions.remove(at: qNumber)

        }

        else{

            NSLog("Quiz is completed")
        }
    }

    @IBAction func Option1(_ sender: Any) {
        if answerNumber == 0{

            selectQuestion()
        }
        else{
             NSLog("Incorrect Answer")
        }

    }

    @IBAction func Option2(_ sender: Any) {

        if answerNumber == 1{

            selectQuestion()
        }
        else{
            NSLog("Incorrect Answer")
        }

    }

    @IBAction func Option3(_ sender: Any) {
        if answerNumber == 2{

            selectQuestion()
        }
        else{
            NSLog("Incorrect Answer")
        }

    }

    @IBAction func Option4(_ sender: Any) {
        if answerNumber == 3{

            selectQuestion()
        }
        else{
            NSLog("Incorrect Answer")
        }

    }
导入UIKit
结构测验{
问:字符串!
变量选项:[字符串]!
回答:Int!
}
类QuizViewController:UIViewController{
@IBVAR问题标签:UILabel!
@IBOutlet var选项:[UIButton]!
变量问题=[测验]()
var qNumber=Int()
var answerNumber=Int()
重写func viewDidLoad(){
super.viewDidLoad()
问题=[测验(问题:“你叫什么名字?”,选项:[“AJ”、“Sami”、“Daniel”、“Sazzad”],答案:1),
小测验(问题:“你的颜色是什么?”,选项:[“红”、“绿”、“蓝”、“橙”],答案:2),
小测验(问题:“你的宠物叫什么名字?”,选项:[“Kitty”、“Marley”、“Button”、“Snoopy”],答案:0),
小测验(问题:“你的单位号码是多少?”,选项:[“204”、“205”、“208”、“209”],答案:3]
选择问题()
//加载视图后执行任何其他设置。
}
重写函数didReceiveMemoryWarning(){
超级。我收到了记忆警告()
//处置所有可以重新创建的资源。
}
func selectQuestion(){

if questions.count这行
if questions.count0
好吧,我希望你是iOS开发的初学者,因为现在的代码方式……这有点让我对XD感到厌烦,尽管它不应该