List selectors for Objective-C object
I have an object, and I want to list all the selectors to which it responds. It feels like this should be perfectly possible, but I'm having trouble finding the APIs. This is a solution based on the runtime C functions: class_copyMethodList returns a list of class methods given a Class object obtainable from an object. #import <objc/runtime.h> [..] SomeClass * t = [[SomeClass alloc] init]; int i=0; unsigned int mc = 0; Method * mlist = class_copyMethodList(object_getClass(t), &mc); NSLog(@"%d methods", mc); for(i=0;i<mc;i++) NSLog(@"Method no #%d: %s", i, sel_getName(method_getName(mlist[i])))