Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There are three cases to consider:</p> <ul> <li><p>use of <code>someObject.something</code></p></li> <li><p>use of <code>self-&gt;something</code></p></li> <li><p>use of <code>otherObject-&gt;something</code></p></li> </ul> <p><code>someObject.something</code> is the <em>dot syntax</em>. It is exactly equivalent to <code>[someObject something]</code> in terms of behavior. It is a method call. Note that <code>something</code> does not have to be declared via an <code>@property</code>. That is, <code>someArray.count</code> or <code>someString.length</code> are both syntactically valid.</p> <p><code>self-&gt;something</code> is accessing an ivar directly. It is a very rarely used syntax; rare is in <em>pretty much never</em>. Instead, just access the ivar directly using <code>something =</code> or <code>[something doSomething]</code>. No need for the <code>-&gt;</code>.</p> <p><code>otherObject-&gt;something</code> is grubbing around <code>otherObject</code>'s instance variables directly. Bad programmer. No donut. Don't do that. It breaks encapsulation and leads to extremely fragile, hard to maintain, code.</p> <hr/> <p>A note on <code>@property</code> declarations. If you have:</p> <pre><code> @property (atomic, strong, readonly) SomeClass *foo; </code></pre> <p>And if you let the compiler automatically <code>@synthesize</code> everything, it will create an instance variable named <code>_foo</code>.</p> <p>You should use direct access in your <code>init</code> and <code>dealloc</code> methods, but -- typically, though not always -- use the setter/getter everywhere else. I.e. in your <code>init</code> you would do <code>_foo = [SomeClass someClassWithSomeMagicValue:42]</code> (assumes ARC, so no <code>retain</code> needed). Everywhere else, you would do <code>[[self foo] castMagic];</code>.</p>
    singulars
    1. This table or related slice is empty.
    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.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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