方法不会覆盖Set <nsobject>的超类中的任何方法

时间:2017-08-02 17:39:12

标签: swift xcode swift3

我正在看几年前我在Swift 1中制作的一个项目。我将代码转换为表示Method does not override any method from its superclass的Swift 3语法后发现错误。我知道它是因为Set是旧的语法但是我用什么替换它?这是一行:

override func touchesBegan(_ touches: Set<NSObject>, with event: UIEvent) {
    self.view.endEditing(true)
}

2 个答案:

答案 0 :(得分:2)

Swift 3中的此方法已更改为:

override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
    super.touchesBegan(touches, with: event)
}
来自Apple的

Reference

答案 1 :(得分:1)

Swift 3

override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
    super.touchesBegan(touches, with: event)
    self.view.endEditing(true)
}