title: iOS: Using UIView's 'drawRect:' vs. its layer's delegate 'drawLayer:inContext:'
body: <p>I have a class which is a subclass of <code>UIView</code>. I am able to draw stuff inside the view either by implementing the <code>drawRect</code> method, or by implementing <code>drawLayer:inContext:</code> which is a delegate method of <code>CALayer</code>. </p>
  
  <p>I have two questions:</p>
  
  <ol>
  <li>How to decide which approach to use? Is there a use case for each one?</li>
  <li><p>If I implement <code>drawLayer:inContext:</code>, it is called (and <code>drawRect</code> isn't, at least as far as putting a breakpoint can tell), even if I don't assign my view as the <code>CALayer</code> delegate by using:</p>
  
  <p><code>[[self layer] setDelegate:self];</code> </p>
  
  <p>how come the delegate method is called if my instance is not defined to be the layer's delegate? and what mechanism prevents <code>drawRect</code> from being called if <code>drawLayer:inContext:</code> is called?</p></li>
  </ol>