inheritance - Returning a subclass from its base class in swift -
I am trying to return an instance of subclass to a method in a superclass so that I can do the method with chaining Can you use methods in both parent and child?
However, I'm getting an error "When I try to sort methods, there is no member of any other name in the baseclass" Here's my code: < Class = "class" class = "class" class = "class" class = "class" class = "class" class = "class" class = "class class class" Kids Class = Child Class Child Class. Some Chinese Meth (). Yue Chainable Mathides ()
It seems that the original series-enabled method is returning 'Return Self' instead of I have also tried to do with generic and failed, this is what I have done: In this case, If you change your code works ChildClass
BaseClass
BaseClass
someChainableMethod method, "BaseClassT is not convertible is".
self: :
Return type depending on the class Base class {func someChainableMethod () - & gt; Self {Return Self}} Class Child Class: Base Class {Fax Some Other Mible () - & gt; Let itself {return self}} Let childClass = childclass () let foo = childClass.someChainableMethod (). SomeOtherChainableMethod ()
Comments
Post a Comment