If you access a property from another class, you should always use the access method or dot notation. This is just basic OO hygiene. In the unlikely event that you find that this causes a bottleneck in the loop or something like that, you might think of some sort of individual solution at this point.
If you are accessing a variable from a class, I think this is normal if you access ivar directly, and not through a property. However, if you set a value, you should always use the property, both to avoid memory leaks, and because the installer may have logic that must be executed.
So:
CGSize sz = [self size]; //ok CGSize sz = self.size; //ok CGSize sz = _size; //ok, but be careful [self setSize:sz]; //ok self.size = sz, //ok _size = sz; // DON'T EVER DO THIS!
However, if you have ivar, which does not even have a property associated with it, you, of course, will need to access it directly (you have little choice ...). Personally, I usually declare properties for all ivars, except for some flags or counters with non-object types, but many people do not.
Felixyz Feb 20 '10 at 17:02 2010-02-20 17:02
source share