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 ChildClass BaseClass

I have also tried to do with generic and failed, this is what I have done: class base class Gt; {Some small Meth () - & gt; T {Return Self}} Class Child Class: Base Class & lt; ChildClass & gt; {Some Other Important Laws (FAQ) - & gt; ChildClass {Return Self}} Let babyCla Ss = child class childClass.SomeChainableMethod (). SomeOtherChainableMethoid ()

In this case, BaseClass someChainableMethod method, "BaseClassT is not convertible is".

If you change your code works 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

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -