1

I was looking at a project that I made in Swift 1 a few years ago. And I noticed an error after converting my code to Swift 3 syntax that said Method does not override any method from its superclass. I know its because the Set is old syntax but what do I replace it with? This is the line:

override func touchesBegan(_ touches: Set<NSObject>, with event: UIEvent) {
    self.view.endEditing(true)
}
karjeezy
  • 61
  • 1
  • 9
  • It's now `Set`. https://stackoverflow.com/a/26811892/1271826 – Rob Aug 02 '17 at 17:43
  • Code for all Swift versions at https://stackoverflow.com/questions/28771896/overriding-method-with-selector-touchesbeganwithevent-has-incompatible-type – Martin R Aug 02 '17 at 19:12

2 Answers2

2

This method in Swift 3 has change to:

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

Reference from Apple

Twitter khuong291
  • 11,328
  • 15
  • 80
  • 116
1

Swift 3

override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
    super.touchesBegan(touches, with: event)
    self.view.endEditing(true)
}
Phyber
  • 1,368
  • 11
  • 25