Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The "@" symbol is interpreted by the compiler as a directive. This is one of the Objective-C 'additions' to the C language. When you declare @property and then @synthesize you are instructing the compiler to create the instructions and corresponding symbols for getters and setters for you. Remember that in the C language, the "=" operator means "assign". Most of the time in the OO context that the Objective-C extensions provide, we are working with <em>pointers</em> (aka references) to isa data structures (Classes in Objective-C). </p> <p>Prior to Objective-C 2.0, all of the getter and setter methods had to be coded by the developer for every attribute which for most cases was copy/paste code. To be completely KVC/KVO compliant requires <em>a lot</em> of very tedious code... willAccessValueForKey, didUpdateValueForKey statements etc. that the new compiler adds for you automatically when you use the @property/@synthesize syntax. This is a huge productivity boost for developers. The dot syntax additions to the language are a little more contentious in the community as this hides the <em>magic</em> the compiler is doing on you behalf to interpret the <code>object.property = anotherObject.property;</code> statement as <code>[object setProperty:[anotherObject property]];</code> </p> <p>From the Apple documentation referenced in other answers</p> <p><strong>Property Declaration Attributes</strong></p> <p>You can decorate a property with attributes by using the form @property(attribute [, attribute2, ...]). Like methods, properties are scoped to their enclosing interface declaration. For property declarations that use a comma delimited list of variable names, the property attributes apply to all of the named properties.</p> <p>If you use the @synthesize directive to tell the compiler to create the accessor method(s), the code it generates matches the specification given by the keywords. If you implement the accessor method(s) yourself, you should ensure that it matches the specification (for example, if you specify copy you must make sure that you do copy the input value in the setter method).</p>
 

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