nico nico - 1 year ago 126
Objective-C Question

@synthesize vs @dynamic, what are the differences?

What are the differences between implementing a


Answer Source

@synthesize will generate getter and setter methods for your property. @dynamic just tells the compiler that 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.

@dynamic also can be used to delegate the responsibility of implementing the accessors. If you implement the accessors yourself within the class then you normally do not use @dynamic.

Super class:

@property (nonatomic, retain) NSButton *someButton;
@synthesize someButton;


@property (nonatomic, retain) IBOutlet NSButton *someButton;
@dynamic someButton;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download