Last active
April 9, 2020 14:39
-
-
Save hcrub/7358358 to your computer and use it in GitHub Desktop.
Objective C Runtime's class_respondsToSelector to detect if whether instances of a class respond to a particular selector.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* class_respondsToSelector | |
* Returns a Boolean value that indicates whether instances of a class respond to a particular selector. | |
* Overall, class_respondsToSelector looks up the selector in the class's method table to see if it has an entry | |
* | |
* BOOL class_respondsToSelector(Class cls, SEL sel) | |
* | |
* Parameters | |
* cls | |
* The class you want to inspect. | |
* | |
* sel | |
* A selector. | |
* | |
* Return Value | |
* YES if instances of the class respond to the selector, otherwise NO. | |
* | |
* Warning | |
* You should usually use NSObject's respondsToSelector: or instancesRespondToSelector: methods instead of this function. | |
* | |
**/ | |
- (BOOL)respondsToSelector: (SEL)aSelector | |
{ | |
return class_respondsToSelector(isa, aSelector); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment