The only difference I observed on my own is that respondsToSelector‘s receiver can either be a class or an instance, while instancesRespondToSelector can only have a class receiver. What else makes them different, though? Are there any performance issues with one or the other?
The only difference I observed on my own is that respondsToSelector ‘s receiver can
Share
Under the hood,
-[NSObject respondsToSelector:]is implemented like this:and
+[Class instancesRespondToSelector:]is implemented like this:(I used Hopper on CoreFoundation to figure this out.)
So, there’s basically no difference. However, you can override
respondsToSelector:in your own class to return YES or NO on a per-instance basis (NSProxydoes this). You can’t do that withinstancesRespondToSelector:.