Hide instance variable from header file in Objective C

后端 未结 10 1040
梦如初夏
梦如初夏 2020-12-30 14:35

I came across a library written in Objective C (I only have the header file and the .a binary). In the header file, it is like this:

@interface MyClass : MyS         


        
10条回答
  •  春和景丽
    2020-12-30 15:00

    For 64 bit applications and iPhone applications (though not in the simulator), property synthesis is also capable of synthesizing the storage for an instance variable.

    I.e. this works:

    @interface MyClass : MySuperClass 
    { 
        //nothing here
    }
    
    @property (nonatomic, retain) MyObject *anObject;
    @end
    
    @implementation MyClass
    @synthesize anObject;
    @end
    

    If you compile for 32 bit Mac OS X or the iPhone Simulator, the compiler will give an error.

提交回复
热议问题