Skip to content

Instantly share code, notes, and snippets.

@JaredCrawford
Created April 10, 2010 15:32
Show Gist options
  • Save JaredCrawford/362073 to your computer and use it in GitHub Desktop.
Save JaredCrawford/362073 to your computer and use it in GitHub Desktop.
Determine private methods on a given class.
#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