iOS----------Runtime 获取属性列表 方法列表
导入
#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);