I've a base class that implements an extension that conforms to a protocol as below:
protocol OptionsDelegate {
func handleSortAndFilter(opt: Options)
}
extension BaseViewController: OptionsDelegate {
func handleSortAndFilter(opt: Options) {
print("Base class implementation")
}
}
I've a subclass "InspirationsViewController" that inherits from BaseViewController. And I'm overriding protocol method in the extension as below:
extension InspirationsViewController {
override func handleSortAndFilter(opt: Options) {
print("Inside inspirations")
}
}
I'm getting error when I override "handleSortAndFilter" function in subclass extension: "Declerations in extensions cannot override yet"
But I'm not seeing similar problem when I implemented UITableView datasource and delegate methods.
How to avoid this error?
InspirationsViewControlleris not a subclass, its an extension. I think you defined it wrong. It should be a classInspirationsViewController: BaseViewController- Hossam GhareebInspirationsViewControlleris subclass ofBaseViewController, this is extension for it. This problem is probably haven't got implemented in Swift, you should do override from main class, extension is for adding more function - Tj3nclass BaseViewController: UIViewController{}andclass InspirationsViewController: BaseViewController {}. - shallowThought