可能重复:
What exactly does @synthesize do?
Can someone explain this @synthesize syntax?
@interface Duck : NSObject {
NSArray *_feathers;
}
@property (nonatomic,retain) NSArray *feathers;
@end
@implementation Duck
@synthesize feathers=_feathers;
@end
我想知道你在做@synthesize feat = _feathers时究竟发生了什么?
答案 0 :(得分:1)
在你的情况下(因为你的财产是非原子的)
@synthesize feathers=_feathers;
等于
- (void)setFeathers:(NSArray *)newFeathers
{
if (newFeathers != _feathers)
{
[_feathers release];
_feathers = [newFeathers retain];
}
}
- (NSArray *)feathers
{
return feathers_;
}