title: Cast an instance of a class to a @protocol in Objective-C
body: <p>I have an object (a UIViewController) which may or may not conform to a protocol I've defined.</p>
  
  <p>I know I can determine if the object conforms to the protocol, then safely call the method:</p>
  
  <pre><code>if([self.myViewController conformsToProtocol:@protocol(MyProtocol)]) {
      [self.myViewController protocolMethod]; // &lt;-- warning here
  }
  </code></pre>
  
  <p>However, XCode shows a warning:</p>
  
  <pre><code>warning 'UIViewController' may not respond to '-protocolMethod'
  </code></pre>
  
  <p>What's the right way to prevent this warning?  I can't seem to cast <code>self.myViewController</code> as a <code>MyProtocol</code> class.</p>