Quote:
Originally Posted by benoitr007
Hmm... If I may ask, what's the advantage of using the getter accessor? I can see for the setter one, but doesn't the getter do exactly the same as just writing enemiesArray? In what cases could it not be harmless to do so?
|
Yeah, that's what I mean by harmless. Since you're just reading, there probably isn't any difference between using the standard getter and reading the instance variable. From a consistency standpoint, I make it a point to use self everywhere.
However, if you would have a reason to write your own custom getter like the one I mentioned, then there
would be a difference, and I imagine that would be a tough bug to track down.
Using [self ...] helps to reinforce that you are using a method. If the implementation of that method would change, that shouldn't affect the code you've already written.