Lets assume we have a simple generic class:
class Foo<T> {
}
next add to this class an extension
which implements UITableViewDatasoure
:
extension Foo: UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
//Code here
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
//Code here
}
}
This construction causes a compiler error with message:
@objc is not supported within extensions of generic classes or classes that inherit from generic classes Non-'@objc' method
'tableView(_:numberOfRowsInSection:)' does not satisfy requirement of '@objc' protocol 'UITableViewDataSource'
Anyone can tell me why? And how to fix that?