Are you talking about outside of the class, or within? If without, then you always use the accessor. First of all, the default visibility for ivars in ObjC is @protected
, so unless you explicitly make them @public
, you have to use an accessor. Aside from this, you use the accessor because you never know if you (or someone else) might subclass your class and change it enough that using the accessor is necessary.
If you're talking about within the class, you don't have to use the accessor, but if you set up @property
values, there's no reason not to use the dot notation, even if you're synthesizing everything. If you're using standard ObjC notation, such as [myObject someVariable]
, then repeated nested messages can get hard to read and cluttered.
Really, the accessor isn't as big a deal as the mutator, because mutators often do more than one thing. Using both getters (outside the class) and setters is good practice.