可能重複:
What exactly does @synthesize do?
Can someone explain this @synthesize syntax?@synthesize羽毛= _feathers?
@interface Duck : NSObject {
NSArray *_feathers;
}
@property (nonatomic,retain) NSArray *feathers;
@end
@implementation Duck
@synthesize feathers=_feathers;
@end
我想知道究竟是什麼,當你做@synthesize羽毛= _feathers要去?
你應該看看這個問題http://stackoverflow.com/questions/822487/how-在可變目標-c-class-work前面加一個下劃線 – Sakares 2012-03-21 08:23:48
開始閱讀[Objective-C](https://developer.apple.com/library /ios/#documentation/Cocoa/Conceptual/ObjectiveC/Introduction/introObjectiveC.html)文檔。特別是關於[屬性]的部分(https://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtPropertyIntrospection.html#//apple_ref/doc/uid/TP40008048-CH101- SW1) – rckoenes 2012-03-21 08:24:46
除了Apple的文檔,有些搜索可以幫助你 - 即使在這個網站。就在昨天,我回答了同樣的問題:http://stackoverflow.com/questions/9771434/iphone-instance-variable-issue/9771696#9771696 – MrTJ 2012-03-21 08:34:40