打印类的方法列表

2022-05-18  本文已影响0人  Jean_Lina
#pragma mark 打印类的方法列表
- (void)getMethodList:(Class)cls {
    unsigned int count;
    NSMutableString *string = [NSMutableString string];
    Method *methodList = class_copyMethodList(cls, &count);
    for (int i = 0; i < count; i++) {
        Method method = methodList[i];
        SEL sel = method_getName(method);
        NSString *methodName = NSStringFromSelector(sel);
        [string appendString:methodName];
        [string appendString:@" "];
    }
    free(methodList);
    NSLog(@"打印方法列表:%@", string);
}
上一篇 下一篇

猜你喜欢

热点阅读