Home > DeveloperSection > Forums > @synthesize vs @dynamic, what are the differences?
Samuel Fernandes
Samuel Fernandes

Total Post:159

Posted on    April-27-2015 1:44 AM

 iPhone iPhone  Ios 

 1 Reply(s)
 1086  View(s)
Rate this:
What are the differences between implementing a @property with @dynamic or @synthesize?

Mayank Tripathi
Mayank Tripathi

Total Post:397

Posted on    April-27-2015 4:34 AM

@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:

Super class:

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

@property (nonatomic, retain) IBOutlet NSButton *someButton;
@dynamic someButton;

Don't want to miss updates? Please click the below button!

Follow MindStick