title: Typecasting return value of methods when returned value is parent class of the typecast?
body: <p>I have code similar to this.</p>
  
  <pre><code>MySubclassOfUIView *view = [aUIPickerView viewForRow:4 forComponent:0];
  </code></pre>
  
  <p>The <strong>viewForRow:forComponent</strong> method of UIPickerView returns a UIView. MySubclassOfUIView is exactly that: a subclass of UIView.</p>
  
  <p>The UIPickerView delegate (not mentioned here) uses an array of MySubclassOfUIView objects to populate the rows of the UIPickerView components. Thus, I know the <strong>viewForRow:forComponent</strong> method is really going to be returning a pointer to an object of type MySubclassOfUIView.</p>
  
  <p>Xcode gives me this warning.</p>
  
  <blockquote>
    <p>Incompatible pointer types initializing 'MySubclassOfUIView*' with an expression of type 'UIView*'.</p>
  </blockquote>
  
  <p>So I figure that I'll typecast it to fix the warning, which gives me this code.</p>
  
  <pre><code>MySubclassOfUIView *view = (MySubclassOfUIView*)[aUIPickerView viewForRow:4 forComponent:0];
  </code></pre>
  
  <p>And the warning goes away.</p>
  
  <p>Please forgive my shaky C and Objective-C skills, but am I doing the right thing (as far as the context given so far)? Is there some other better way to handle this situation?</p>