title: How to cast Class object to conformance witih protocol
body: <p>I'm trying to cast a Class object to a certain protocol, which defines class methods (+) that that class implements.</p>
  
  <p>I know how to do this with (id&lt; protocol>), as outlined <a href="https://stackoverflow.com/questions/617616/cast-an-instance-of-a-class-to-a-protocol-in-objective-c">in this question</a>, but I can't seem to figure out the right way for Class objects.</p>
  
  <p>The basic scenario is as follows.</p>
  
  <p>I have a protocol:</p>
  
  <pre><code>@protocol Protocol &lt;NSObject&gt;
  + (id)classMethod:(id)arg;
  @end
  </code></pre>
  
  <p>I then have a function which accepts a Class object, which it knows sometimes conforms to the protocol based on another argument (this is obviously very simplified):</p>
  
  <pre><code>- (id)someMethodWithClass:(Class)cls andUseArg:(BOOL)arg
  {
      id instance;
      if (arg != nil) {
          instance = [(Class&lt;Protocol&gt;)cls classMethod:arg];
      }
  }
  </code></pre>
  
  <p>Now I don't get any warnings on this, and it looks right to me.  (I'm not going to see any errors in any case, because I can guarantee that if arg != nil then the class conforms.)</p>
  
  <p>However, I'm not getting autocompletion in Xcode, which makes me wonder if this is the right way to do it.  Any thoughts?  (Note that I am not interested in instance being id&lt; Protocol>.)</p>