Swift 方法不会覆盖集合的超类中的任何方法<;NSObject>;
我在看几年前我在Swift 1上做的一个项目。在将代码转换为Swift 3语法后,我注意到一个错误,即Swift 方法不会覆盖集合的超类中的任何方法<;NSObject>;,swift,xcode,swift3,Swift,Xcode,Swift3,我在看几年前我在Swift 1上做的一个项目。在将代码转换为Swift 3语法后,我注意到一个错误,即方法不会覆盖其超类中的任何方法。我知道它是因为集合是旧语法,但是我应该用什么来替换它呢?这是一行: override func touchesBegan(_ touches: Set<NSObject>, with event: UIEvent) { self.view.endEditing(true) } override func touchsbegind(touch:
方法不会覆盖其超类中的任何方法。我知道它是因为集合是旧语法,但是我应该用什么来替换它呢?这是一行:
override func touchesBegan(_ touches: Set<NSObject>, with event: UIEvent) {
self.view.endEditing(true)
}
override func touchsbegind(touch:Set,带有事件:UIEvent){
self.view.endEditing(true)
}
Swift 3中的此方法已更改为:
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesBegan(touches, with: event)
}
override func touchsbegind(touch:Set,带有事件:UIEvent?){
super.touchesbeated(touches,with:event)
}
来自苹果公司的Swift 3
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesBegan(touches, with: event)
self.view.endEditing(true)
}
override func touchsbegind(touch:Set,带有事件:UIEvent?){
super.touchesbeated(touches,with:event)
self.view.endEditing(true)
}
现在是Set
。所有Swift版本的代码