I'm trying to make UITableView
notify its delegate of contentSize
when contentSize
of UITableView
is updated.
So I added property observer to contentSize
of UITableview
that calls delegation method named tableView(_ tableView: didUpdateContentSize contentSize:)
.
Then I extended UITableViewDelegate
so that UIViewController
conforming UITableViewDelegate
can declare tableView(_ tableView: didUpdateContentSize contentSize:)
for its use case.
extension UITableView {
override open var contentSize: CGSize {
didSet {
self.delegate?.tableView(self, didUpdateContentSize: contentSize)
}
}
}
extension UITableViewDelegate {
func tableView(_ tableView: UITableView, didUpdateContentSize contentSize: CGSize)
// Error: "Expected '{' in body of function declaration"
}
But in extension code of UITableViewDelegate
, it gets an error "Expected '{' in body of function declaration"
Is there no way to extend existing protocol (like UIKit
delegate protocols) without function declaration?
I'd like to accomplish my intention without making subclass of UITableView
.