title: Objective-C dynamic_cast?
body: <p>Is there an Objective-C equivalent of C++'s dynamic_cast?</p>
  
  <p>It can be faked using this:</p>
  
  <pre><code>MyClass *safeObject = [object isKindOfClass: [MyClass class]]
                        ? (MyClass *)originalObject : nil;
  </code></pre>
  
  <p>But this is a lot of code to type, even if I don't need to type it often.</p>
  
  <p>I am a bit rusty so this might not be quite right, but I believe the equivalent in C++ would be:</p>
  
  <pre><code>MyClass safeObject = dynamic_cast&lt;MyClass&gt;(orginalObject);
  </code></pre>
  
  <p>The context here is a block where the parameter is defined as a type of a more generic class, but in this block I "know" it's a specific subclass. Nevertheless, I don't want to just cast it blindly with <code>(MyClass *)originalObject</code> and ignore a theoretically possible error.</p>
  
  <p>To be clear, while I'd love a <code>dynamic_cast</code>, I'd be happy with an alternate approach to safely handle this case as well.</p>