The following code throws an error
protocol WhatA: AnyObject {
func doThat()
}
protocol WhatB: WhatA {
func doThis()
}
class SomethingA {
weak var delegate: WhatA?
}
class SomethingB: SomethingA {
weak var delegate: WhatB?
}
Property 'delegate' with type 'WhatB?' cannot override a property with type 'WhatA?'
UIKit has no problems with the following
open class UIScrollView : UIView, NSCoding, UIFocusItemScrollableContainer {
weak open var delegate: UIScrollViewDelegate?
}
open class UITableView : UIScrollView, NSCoding, UIDataSourceTranslating {
weak open var delegate: UITableViewDelegate?
}
Why does this work in UIKit? The accepted answer for this question suggests this is not possible.