Skip to content

Instantly share code, notes, and snippets.

@vmihaylenko
Created September 11, 2014 09:12
Show Gist options
  • Save vmihaylenko/74c395709bedb15d14db to your computer and use it in GitHub Desktop.
Save vmihaylenko/74c395709bedb15d14db to your computer and use it in GitHub Desktop.
Show all methods in class
Class currentClass = [NSClassFromString(@"ClassName") 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);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment