Synthesize allows you to use the getter and setter methods, which are called automatically depending on whether you are trying to read or write a value. For the myView property:
myView = newView1; // using direct ivar access myobject.myView = newvew1; // eq [myobject setMyView:newvew1]; where setMyView: is generated for you automatically with respect to assign/retain, the same for reading: newvew1 = myobject.myView; // newvew1 = [myobject myView:newvew1];
the generated receiver / setter names are configured using setter = / getter = if you do not need the installer to use readonly.
You cannot forbid other classes to use the synthesized getter and setter, ivars are protected by @project by default, and if you want to give other classes access to ivars, you can declare them in @public:
@interface myClass (){ UIImageView *myView; // this is protected @public UIImageView *myPublicView; // this is public }
source share