獲取一個(gè)類的所有方法
unsigned int methodCount;
Method *methodList = class_copyMethodList(currentClass, &methodCount);
for (NSInteger i = 0; i < methodCount; i++) {
Method method = methodList[i];
NSString *methodName = [NSString stringWithCString:sel_getName(method_getName(method))
encoding:NSUTF8StringEncoding]
NSLog(@"%@",methodName);
}
獲取一個(gè)類的所有變量
unsigned int count = 0;
Ivar *ivars = class_copyIvarList([currentClass class], &count);
for (int i = 0; i < count; i++) {
Ivar ivar = ivars[i];
const char *name = ivar_getName(ivar);
NSString *objcName = [NSString stringWithUTF8String:name];
NSLog(@"%d : %@",i,objcName);
}