2017-08-02 54 views
1

我正在看一个项目,我在几年前在Swift 1中。在将我的代码转换为Swift 3语法之后,我注意到一个错误,它说Method does not override any method from its superclass。我知道它是因为Set是旧的语法,但我用什么替换它?这是该行:方法不会覆盖任何方法从它的超类集<NSObject>

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

它现在'设置 '。 https://stackoverflow.com/a/26811892/1271826 – Rob

+0

代码为所有Swift版本在https://stackoverflow.com/questions/28771896/overriding-method-with-selector-touchesbeganwithevent-has-incompatible-type –

回答

1

这种方法在斯威夫特3有变化:

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

Reference从苹果

1

斯威夫特3

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