Hello
I am a programming novice so apologies if my questions are daft. I have some experience programming with VBA, which I think is where some of my confusion comes from when trying to reconcile how things works with how I understand it works in VBA.
I am trying to understand the role properties play. In VBA, my understanding of a property is it sits over the top of a privately declared variable in order to exercise some control and validation over the assignment of a value to the underlying private variable. Therefore, the private variable has to be declared and then getters and setters are written to deal with the assignment.
When reading about how to do it in Xcode (or should that be objective c?) it doesn't seem like the underlying variable has to be declared - if you put the appropriate @property code in the header and the @synthesize code in the implementation file, the underlying variable presumably must get created in the background?
However, when I was reading about setting up a view controller with any necessary outlets, you declare the IBOutlet objects and then also write them out with the @property syntax in order to generate their getters an setters, so in this case the variables are declared in addition to the property code.
Can anyone explain the role of properties and how they work please, first of all, in as straightforward a manner as possible?
Thank you in advance.
I am a programming novice so apologies if my questions are daft. I have some experience programming with VBA, which I think is where some of my confusion comes from when trying to reconcile how things works with how I understand it works in VBA.
I am trying to understand the role properties play. In VBA, my understanding of a property is it sits over the top of a privately declared variable in order to exercise some control and validation over the assignment of a value to the underlying private variable. Therefore, the private variable has to be declared and then getters and setters are written to deal with the assignment.
When reading about how to do it in Xcode (or should that be objective c?) it doesn't seem like the underlying variable has to be declared - if you put the appropriate @property code in the header and the @synthesize code in the implementation file, the underlying variable presumably must get created in the background?
However, when I was reading about setting up a view controller with any necessary outlets, you declare the IBOutlet objects and then also write them out with the @property syntax in order to generate their getters an setters, so in this case the variables are declared in addition to the property code.
Can anyone explain the role of properties and how they work please, first of all, in as straightforward a manner as possible?
Thank you in advance.