Call subclass's method from its superclass

前端 未结 6 2150
囚心锁ツ
囚心锁ツ 2020-12-03 12:01

I have two classes, named Parent and Child, as below. Parent is the superclass of Child I can call a method of the super

6条回答
  •  情话喂你
    2020-12-03 12:26

    Technically you can do it. But I suggest you to alter your design. You can declare a protocol and make your child class adopt that protocol. Then you can have to check whether the child adopts that protocol from the super class and call the method from the super class.

提交回复
热议问题