Hey guys,
I've asked this question on several forums now, but couldn't get a satisfying answer.
Having understood the main purpose of properties, which is the generation of getters / setters, and how to access them, I'm still struggling with the question of when it's best to have an instance variable AND a property, named the same or differently, and when you should just use a property OR a variable.
For example, when you create a new project in Xcode and choose one of the templates (ViewBased, NavBased, etc. ) there is always JUST a window-property in the AppDelegate.h file and no instance variable.
So...I do know that you access the property by using self.propertyName or by calling the name you choose in the @synthesize line, I just would like to understand when to use property + variable, and whether there are situations where it's more common to use property only OR variable only, because I can't believe this is kind of random...
Best wishes,
schnigges
I've asked this question on several forums now, but couldn't get a satisfying answer.
Having understood the main purpose of properties, which is the generation of getters / setters, and how to access them, I'm still struggling with the question of when it's best to have an instance variable AND a property, named the same or differently, and when you should just use a property OR a variable.
For example, when you create a new project in Xcode and choose one of the templates (ViewBased, NavBased, etc. ) there is always JUST a window-property in the AppDelegate.h file and no instance variable.
So...I do know that you access the property by using self.propertyName or by calling the name you choose in the @synthesize line, I just would like to understand when to use property + variable, and whether there are situations where it's more common to use property only OR variable only, because I can't believe this is kind of random...
Best wishes,
schnigges