Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swift 方法不会覆盖集合的超类中的任何方法<;NSObject>;_Swift_Xcode_Swift3 - Fatal编程技术网

Swift 方法不会覆盖集合的超类中的任何方法<;NSObject>;

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:

我在看几年前我在Swift 1上做的一个项目。在将代码转换为Swift 3语法后,我注意到一个错误,即
方法不会覆盖其超类中的任何方法。我知道它是因为集合是旧语法,但是我应该用什么来替换它呢?这是一行:

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版本的代码