Properties and accessors in Objective-C

前端 未结 1 1835
孤城傲影
孤城傲影 2020-11-27 08:33

Does the following code call an accessor \"set\" function or does it modify the pointer myMember directly?

aClass.h

@interface MyClass :         


        
相关标签:
1条回答
  • 2020-11-27 09:10

    Without the self. notation, the instance variable is modified directly. With it, the property setter is called (and since you made it a retain property, the new pointer that it's being set to will be sent a retain message).

    See Apple's documentation on declaring and accessing properties.

    0 讨论(0)
提交回复
热议问题