導入 #import <objc/runtime.h> unsigned int count; Method *methods = class_copyMethodList([UIAlertAction class], &count); for (int i = 0; i < count; i++) ...
導入
#import <objc/runtime.h>
unsigned int count;
Method *methods = class_copyMethodList([UIAlertAction class], &count);
for (int i = 0; i < count; i++) {
Method method = methods[i];
SEL selector = method_getName(method);
NSString *name = NSStringFromSelector(selector);
NSLog(@"method_getName:%@",name);
}
unsigned int numIvars;
Ivar *vars = class_copyIvarList([UIAlertAction class], &numIvars);
NSString *key=nil;
for(int i = 0; i < numIvars; i++) {
Ivar thisIvar = vars[i];
key = [NSString stringWithUTF8String:ivar_getName(thisIvar)];
NSLog(@"variable_name :%@", key);
}
free(vars);