Created
November 6, 2014 10:22
-
-
Save fahied/5e46ecf65ea0a9e11e61 to your computer and use it in GitHub Desktop.
Listing Methods at Runtime in Objective C
This file contains 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
-(void)listAllClassMethods | |
{ | |
// Iterate over the class and all superclasses | |
Class currentClass = [self class]; | |
while (currentClass) { | |
// Iterate over all instance methods for this class | |
unsigned int methodCount; | |
Method *methodList = class_copyMethodList(currentClass, &methodCount); | |
unsigned int i = 0; | |
for (; i < methodCount; i++) { | |
NSLog(@"%@ - %@", [NSString stringWithCString:class_getName(currentClass) encoding:NSUTF8StringEncoding], [NSString stringWithCString:sel_getName(method_getName(methodList[i])) encoding:NSUTF8StringEncoding]); | |
} | |
free(methodList); | |
currentClass = class_getSuperclass(currentClass); | |
} | |
} | |
// source - http://pagesofinterest.net/blog/2012/01/listing-methods-at-runtime-in-objective-c/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment