How to resolve in swift (2.0) that case: we have two protocols:
protocol SuperDelegate{
func handleSuccess(rsp: BaseRsp)
}
protocol ChildOfSuperDelegate: SuperDelegate {
func handleSuccess(rsp: ChildOfBaseRsp)
}
and some place in code where we want do:
class A{
var delegate:SuperDelegate?
func foo(){
delegate?.handleSuccess(childOfBaseRspObj)
}
}
class Xyz:ChildOfSuperDelegate{
func handleSuccess(rsp: ChildOfBaseRsp){
print("Great!")
}
}
but compiler not founding inheritence in protocols (handleSuccess have function with base and child parameters) there are compile error:
Type 'Xyz' does not conform to protocol 'SuperDelegate'
. How to resolve them? What is the best way to only implements ChildOfSuperDelegate methods but class "A" use SuperDelegate variable.
Meybe I must use generic types to have somethink like inheritance in protocols.