Does the following code call an accessor “set” function or does it modify the pointer myMember directly?
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 setMyMember is being called, or if the pointer of myMember is being modified directly.
Likewise, is myMember = [NSArray array] identical to self.myMember = [NSArray array]?
Without the
self.notation, the instance variable is modified directly. With it, the property setter is called (and since you made it aretainproperty, the new pointer that it’s being set to will be sent aretainmessage).See Apple’s documentation on declaring and accessing properties.