instance variables in @interface; header vs implementation

前端 未结 2 1461

Is there any difference between declaring a private instance variable in the header vs declaring it in the implementation?

in TestObj.h

@interface TestOb         


        
2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-19 22:26

    Greg Parker's comment on the accepted answer is the best answer here:

    There is one functional difference: ivars in the class's @interface are @protected by default, and ivars in a class extension @interface or in @implementation are @private by default.

提交回复
热议问题