Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>Update after seeing your edit:</strong> </p> <p>A class object responds to <code>respondsToSelector:</code> just fine, as you're probably aware. In a test application, I can do both of the following without any compiler warnings:</p> <pre><code>NSLog(@"Responds to selector? %i", [MyObject respondsToSelector:@selector(respondsToSelector:)]); NSLog(@"Responds to selector? %i", [[MyObject class] respondsToSelector:@selector(respondsToSelector:)]); </code></pre> <p>However, you've declared a protocol on your variable, so it assumes that the class object you're pointing to implements those methods. The simplest solution would be to cast <code>someClass</code> as an <code>id</code> for the purpose of calling <code>respondsToSelector:</code>. A somewhat cleaner solution would be to declare your own <code>@protocol</code> which declares <code>+respondsToSelector:(SEL)selector</code>, and then declare <code>someClass</code> as follows:</p> <pre><code>Class&lt;SomeProtocol, ClassRespondingToSelector&gt; someClass = ... </code></pre> <p>Finally, be sure to file a bug with Apple at <a href="http://bugreporter.apple.com" rel="noreferrer">http://bugreporter.apple.com</a>. Include a simple test application so that it's very clear what you're doing. They welcome such bug reports, even if they've been submitted in the past, as it helps them prioritize the fixes.</p> <p>Final note: this is probably happening because in theory, you could have chosen to implement a root object entirely separate from NSObject, and in that case, it <em>wouldn't</em> respond to <code>-respondsToSelector:</code>. <code>-[NSObject respondsToSelector:]</code> is actually declared in the <code>NSObject</code> protocol, not the class definition. The <code>NSObject</code> protocol is actually where most of what you know as <code>NSObject</code> actually lives. One could argue that <code>+respondsToSelector:</code> should also be in there, but as of now, it's not. And since you've provided a protocol list, and the method isn't in there, it gives you a warning to make sure you know what you're doing.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload