表达式解析为未使用的函数只有实例方法可以声明为@IBAction

时间:2015-09-25 16:44:43

标签: swift

我正在关注一个youtube系列,我完全和电影中的那个人一样,但我仍然会收到错误,请帮助。 (:

如果你知道答案,请帮助。

@IBAction func resetClicked(sender:UIButton) {

            func reset() {

            }
            plays = [:]
            img1.image = nil
            img2.image = nil
            img3.image = nil
            img4.image = nil
            img5.image = nil
            img6.image = nil
            img7.image = nil
            img8.image = nil
            img9.image = nil
        }


    }

    func checkForWin() {
        var whoWon = ["I":0,"you":1]
        for (key,value) in whoWon {
            if((plays[7] == value && plays[8] == value && plays[9] == value))
             (plays[4] == value && plays[5] == value && plays[6] == value)
             (plays[1] == value && plays[2] == value && plays[3] == value)
             (plays[1] == value && plays[4] == value && plays[7] == value)
             (plays[2] == value && plays[5] == value && plays[8] == value)
             (plays[1] == value && plays[5] == value && plays[9] == value)
            (plays[3] == value && plays[5] == value && plays[7] == value)) {

                self.userMessage.hidden = false
                self.userMessage.text = "Looks like \(key) won"
                self.reset.hidden = false
                self.done = true
            }






        }

    }

    func aiDeciding2() {

    }
    func aiTurn() {


    }

1 个答案:

答案 0 :(得分:0)

您无法在IBAction中声明函数。你的错误是

func reset() {
}

还要确保您的IBAction在视图控制器代码中