title: Dot notation vs square brackets and casting in Objective-C
body: <p>Which of the following is best practice in Objective-C?</p>
  
  <pre><code>UITableView* view = (UITableView*) [self view];
  [view setSeparatorColor:[UIColor blackColor]];
  [view release];
  </code></pre>
  
  <p>vs.</p>
  
  <pre><code>((UITableView*) self.view).separatorColor = [UIColor blackColor];
  </code></pre>
  
  <p>Or is there a better way of writing this? <code>self.view</code> is a <code>UIView*</code>.</p>
  
  <p>I'm asking both because I have a weird looking cast (maybe there's a better way?) and because of the following text from the official documentation, which hints that it's more than just a matter of style or personal preference:</p>
  
  <blockquote>
    <p>A further advantage is that the compiler can signal an error when it detects an attempt to write to a read-only declared property. If you instead use square bracket syntax for accessing variables, the compiler—at best—generates only an undeclared method warning that you invoked a nonexistent setter method, and the code fails at runtime.</p>
  </blockquote>