I have been working my way through several books on X-code, the Apple document files, and YouTube Tutorials. I notice, though, that some authors (i.e. some books) put @property statements for all their IBOutlets — imageviews, labels, and buttons, while in other books, the objects listed in the header are not “propertied” and synthesized in the .m.
I know it has something to do with setters and getters and accessors, but would someone mind clarifying for me (without those words, if possible) when you use @property and when you don’t? Sorry for asking what seems to be a dumb question, but I haven’t yet got an intuitive grasp of what’s really happening.
Thanks.
-Rob
Whenever you need to modify something like a UIButton or anything that needs you to use a pointer to access it, you use the @property. All this does is create ‘Getter and Setter’ methods. If you’ve programmed in another language you probably understand what those are, but if you don’t, it’s hard to explain. If you want to understand better why the @property exists, I’d learn some c++. But below is an explanation in Objective C terms of what it is
The @property is an Objective-C directive which declares the property. The “retain” in the parenthesis specifies that the setter should retain the input value, and the rest of the line simply specifies the type and the name of the property.
The @synthesize directive automatically generates the setters and getters for us, so all we have to implement for this class is the dealloc method.
Great website that I got this information from, and has much more: http://cocoadevcentral.com/d/learn_objectivec/