Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In the <code>@synthesize</code> syntax, the left side of the <code>=</code> <em>(which is just a character the synthesize uses for this syntax, not the assignment operator)</em> is the name of the property <em>(and associated methods)</em>, and the right side of the <code>=</code> is the instance variable to use for the named property.</p> <p>In the above example, <code>@synthesize fetchedResultsController=fetchedResultsController_</code> creates a <strong>fetchedResultsController</strong> getter method and a <strong>setFetchedResultsController:</strong> setter method, both using the <strong>fetchedResultsController_</strong> instance variable for storage. </p> <p>Likewise, <code>@synthesize managedObjectContext=managedObjectContext_</code> creates <strong>managedObjectContext</strong> and <strong>setManagedObjectContext:</strong> accessor methods, both backed by the <strong>managedObjectContext_</strong> instance variable.</p> <p>If the “right sides” had not been explicitly specified <em>(if the declaration read <code>@synthesize fetchedResultsController, managedObjectContext;</code>)</em>, synthesize would've assumed the same name for the instance variable as the property.  Some Objective-C programmers dislike leaving it at this default behaviour because it can be easy to make the mistake of intending to set local function-scope variable and instead setting an instance variable instead.  Using an underscore for all instance variables makes their intent clearer.</p> <p>Just to be clear, multiple <code>@synthesize</code> properties can be combined into one by comma separating; each is still its own declaration such that the above is fully equivalent to:</p> <pre><code>@synthesize fetchedResultsController=fetchedResultsController_; @synthesize managedObjectContext=managedObjectContext_; </code></pre> <p>Also worth nothing, in newer Xcode/iOS versions instance variables will be created automatically if not explicitly defined, and @synthesize declarations are also assumed if not specified.  These differences are explained in Apple's quick-ref <a href="https://developer.apple.com/library/ios/#releasenotes/ObjectiveC/ObjCAvailabilityIndex/" rel="nofollow" title="Objective-C Feature Availability Index">Objective-C Feature Availability Index</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload