Created
April 10, 2010 15:32
-
-
Save JaredCrawford/362073 to your computer and use it in GitHub Desktop.
Determine private methods on a given class.
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
#include <objc/objc.h> | |
#include <objc/message.h> | |
#include <objc/runtime.h> | |
+(void)getMethodsForClass:(id)class{ | |
unsigned int count = 0; | |
Method *methods = class_copyMethodList(object_getClass(class), &count); | |
for (int i=0; i < count; i++) { | |
Method method = methods[i]; | |
SEL selector = method_getName(method); | |
NSString *methodNameString = [NSString stringWithCString:(const char *)selector encoding:NSASCIIStringEncoding]; | |
NSLog(@"Class Method: %s", selector); | |
} | |
methods = class_copyMethodList(class, &count); | |
for (int i=0; i < count; i++) { | |
Method method = methods[i]; | |
SEL selector = method_getName(method); | |
NSString *methodNameString = [NSString stringWithCString:(const char *)selector encoding:NSASCIIStringEncoding]; | |
NSLog(@"Instance Method: %s", selector); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment