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 declaration? Is it bad form not to?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…