首先導(dǎo)入頭文件#import <objc/runtime.h>
#pragma mark - 獲取類的所有方法
- (NSArray *)getClassMethods {
NSMutableArray *mutArr = [NSMutableArray array];
unsigned int outCount;
/** 第一個參數(shù):要獲取哪個類的方法
* 第二個參數(shù):獲取到該類的方法的數(shù)量
*/
Method *methodList = class_copyMethodList([UIView class], &outCount);
// 遍歷所有屬性列表
for (int i = 0; i<outCount; i++) {
SEL name = method_getName(methodList[i]);
[mutArr addObject:NSStringFromSelector(name)];
}
return [NSArray arrayWithArray:mutArr];
}