@synthesize vs @dynamic, what are the differences?

Total Post:159

iPhone  Ios 
 1758  View(s)
Rate this:
What are the differences between implementing a @property with @dynamic or @synthesize?
  1. Post:397

    Re: @synthesize vs @dynamic, what are the differences?

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

      Modified On Apr-09-2018 04:44:31 AM