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

后端 未结 4 694
天命终不由人
天命终不由人 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条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-29 09:05

    I do something like this

    @protocol MyProtocol
    - (void) foo;
    - (void) bar;
    @end
    
    @interface BaseAbstract
    - (void) bar; // give a default implementation
    @end
    
    @interface Derived_1 : BaseAbstract
    // you will get a compiler warning for foo() since it is not implemented
    
    // you will NOT get compiler for bar() warning since a default 
    // implementation is inherited
    @end
    
    @interface Derived_2 : BaseAbstract
    @end
    
    typedef BaseAbstract Base;
    

提交回复
热议问题