Since I've upgraded to Xcode 9 / Swift 4 some of my UITableViewDelegate
methods are not called anymore
Asked
Active
Viewed 586 times
0

Lucas van Dongen
- 9,328
- 7
- 39
- 60
1 Answers
0
As of Xcode 9 / Swift 4 all Objective-C methods should be marked @objc
. The compiler does a reasonable job of recognizing where it should be applied however it doesn't figure out inheritance. For example:
class Delegate: NSObject, UITableViewDelegate {
}
class SuperDelegate: Delegate {
override func tableView(_ tableView: UITableView, willSelectRowAt indexPath: IndexPath) -> IndexPath? { return indexPath }
}
This will not generate any warning, crashing or build error. However your line will not be called until you add @objc
:
@objc class SuperDelegate: Delegate {
override func tableView(_ tableView: UITableView, willSelectRowAt indexPath: IndexPath) -> IndexPath? { return indexPath }
}

Lucas van Dongen
- 9,328
- 7
- 39
- 60