I know it’s often advisable to use the @property accessors, and I know it’s important to use self.myView = x instead of mView = x, but:
-
Isn’t
myView.framesufficient? The AtomicElementFlippedView.m file in TheElements hasself.wikipediaButton.frame=buttonFrame;. Shouldn’t I leave outselfif I’m getting/setting a property of my ivar and not the ivar itself? -
It also does
[self.wikipediaButton addTarget:...];. But shouldn’t I leave outselfhere as well? Shouldn’t I always call a function on the ivar, not the property? I.e.,[wikipediaButton addTarget:...];
Thanks!
Matt
Both will work.
The main reason for using getters within a class is that code changes are easy. If you decide to store your data in a different fashion or to build it dynamically on request, there is a single point of change. With views it’s not that important most of the time, but it can come handy when you replace that view with a complete view hierarchy (your original view being maybe part of it).