In a modern Objective-C environment, you can do something like this:
@interface MyClass : NSObject { } @property NSString *stringProperty; @end @implementation MyClass @synthesize stringProperty; @end
I agree with the modern runtime environment, it not only synthesizes accessors for my property, but also the instance variable itself, so I could say in one of these methods of the class [stringProperty length]; , and this will work just as if I have declared an instance variable.
I started using this in all of my code because, well, this is another thing that I have to write over and over again. And I heard with the clang 2.0 compiler, I can even skip @synthesize (but that's another matter). But I was wondering what are some of the disadvantages of this? When may I need an instance variable in addition to my properties?
I know what sometimes happens when I want to keep a private variable and not provide access to it from outside (but then I usually just declare the property in my private class extension or donβt create a property for it if I don't need accessors for it).
Is there a time when I would not want to do this?
source share