If you're just accessing them, there's not much reason to use self.member
. If you're doing assignment, it's good if you're doing more than the simple @property (assign)
parameter--for instance, retain, copy, etc, so it can save on code you're writing. An example:
myObject = anotherObject;
self.myObject = anotherObject;
The second choice will ensure that you're actually assigning the object the way you want (getting a copy, increasing the retain count, etc.). It's no different from [self setMyObject:anotherObject]
.
Since the dot-notation gets substituted for a message by the compiler (similar to how x[5]
becomes *(x + 5*sizeof(x))
in regular array work), there's no overhead or extra efficiency in using dot-notation over regular messages.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…