2017-08-02 50 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) 
} 
相關問題