打印类的方法列表

#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);
}

你可能感兴趣的:(打印类的方法列表)