I'm defining a protocol called PanelController in which I'd like to store a PanelView. PanelView itself is a subclass of UIView and defines the basic structure of panel. I have three different views that subclass PanelView: LeftPanel, MidPanel, and RightPanel. For each of those panels I'd like to define a xxxPanelController (left, mid, right) that conforms to the PanelController protocol.
The issue I'm running up against is in the protocol and xxxPanelController
protocol PanelController {
var panelView: PanelView { get set }
...
}
and
class LeftPanelController: UIViewController, PanelController {
var panelView = LeftPanelView()
...
}
where
class LeftPanelView: PanelView {
...
}
and (one last piece...)
class PanelView: UIView {
...
}
I get an error saying that: LeftPanelController does not conform to protocol PanelController for an obvious reason: panelView is of type LeftPanelView not PanelView. This seems really limited to me, though, because LeftPanelView is a subclass of PanelView so it should just work! But it doesn't!
Can someone explain to me why this is, and if anyone can come up with one, a possible workaround? Thanks!