How to avoid “incomplete implementation” warning in partial base class

后端 未结 4 688
天命终不由人
天命终不由人 2020-12-29 08:20

I have created a protocol that my classes need to implement, and then factored out some common functionality into a base class, so I did this:

@protocol MyPr         


        
4条回答
  •  -上瘾入骨i
    2020-12-29 09:00

    In Obj-C, there is no concept of abstract class. So that, you can not let your Base class to be abstract (which means dont' implements all methods in the protocol). You can only have 2 choices. Let the method in protocol to be optionol and then implements it yourself in the derived class. Or, force all classes in the hierarchy to implement it, but let the caller to be careful not call the incorrect method ones

提交回复
热议问题