Currently I can write a class like this:
@interface Foo
@property(assign) float bar;
@end
@implementation Foo
- (void) someMethod
{
_bar = 4;
}
@end
It’s convenient that I can leave out the @synthesize boilerplate list, and if I can get used to the underscore notation, I get the nice readable rule that everything named _foo is an instance variable. Is it OK to use the auto-generated instance variables like this? I mean, maybe they’re supposed to be invisible even to the class author?
Yes, it is absolutely OK to use these variables.
Dropping the
@synthesizerequirement altogether was a convenience: the@synthesize xyzis now inserted implicitly – that is the only difference. Designers of the compiler reasoned that since they can unambiguously identify situations when you want to synthesize accessors vs. situations when you provide custom implementations, it is reasonable to stop asking you for an explicit@synthesize.