Objective C: Why do we declare ivars in the .h member area if @property seems to do it automatically?
问题 In implementing an interface it seems the common method in tutorials and literature is to declare an ivar and then set the @property then @synthesize . @interface MyClass : NSObject { NSString *myString; } @property (nonatomic, retain) NSString *myString; @end However, omitting the explicit declaration and just putting @property has the same effect. @interface MyClass: NSObject { } @property (nonatomic, retain) NSString *myString; @end So how come most people use @property and an explicit