Create a MyTableView that inherits UITableView
UUITableView#delegate:UITableViewDelegate 「 is UUIScrollView#delegate:
I'd like to expand to MyTableView#delegate:MyTableViewDelegate
However, if you write normally, the error will be as follows:
class MyTableView:UITableView{
override vardelegate: MyTableViewDelegate?//Property 'delegate' with type 'MyTableViewDelegate?'cannot override a property with type 'UITableViewDelegate?'
}
protocolMyTableViewDelegate:UITableViewDelegate{
}
What should I do?
swift ios
I think it's better to name a different variable and substitute it for the original delivery.
class MyTableView:UITableView{
varmyDelegate:MyTableViewDelegate?{
set(value){
self.delegate=value
}
get{
return self.delegate as ?MyTableViewDelegate
}
}
}
By the way, I do not recommend inheriting UITableView unless you are very particular about UI.
© 2024 OneMinuteCode. All rights reserved.