Properties and Accessors in Objective-C

Does the following code invoke the install function or change the pointer myMemberdirectly?

aClass.h

@interface MyClass : NSObject {
    NSArray *myMember;
}

@property (nonatomic, retain) NSArray *myMember;

aClass.c

@implementation GameplayScene

@synthesize myMember;

- (id) init {
    if ( (self = [super init]) )
    {
        myMember = [NSArray array];
    }
}

In other words, I would like to know if the method is called setMyMember, or if the pointer myMemberchanges directly.

Similarly, myMember = [NSArray array]identical self.myMember = [NSArray array]?

+1
source share
1 answer

Without a designation self., the instance variable changes directly. Using it, the setter property is called (and since you made it a property retain, a new pointer will be sent to which a message will be sent retain).

. Apple .

+5

All Articles