@synthesize vs. @dynamic
@synthesize will generate getter and setter methods and corresponding instance variable for your property. @dynamic just tells the compiler that the instance variable, the getter and setter methods are implemented not by the class itself but somewhere else (like the superclass or will be provided at runtime).
Uses for @dynamic are e.g. with subclasses of NSManagedObject (CoreData) or when you want to create an outlet for a property defined by a superclass that was not defined as an outlet (the property of the subclass is just used as an interface. Its actual variable and implement is in the super class):
Super class:
@property (nonatomic, retain) NSButton *someButton; ... @synthesize someButton;
Subclass:
@property (nonatomic, retain) IBOutlet NSButton *someButton;
...
@dynamic someButton;
参考:http://stackoverflow.com/questions/1160498/synthesize-vs-dynamic-what-are-the-differences

浙公网安备 33010602011771号