我正在看几年前我在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)
}
答案 0 :(得分:2)
Swift 3中的此方法已更改为:
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesBegan(touches, with: event)
}
来自Apple的
答案 1 :(得分:1)
Swift 3
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesBegan(touches, with: event)
self.view.endEditing(true)
}