可以看到苹果SDK的私有方法

方法一

想看什么类 就 把UIView换成你想要的

#import <objc/runtime.h> 

UIView * t = [[UIView alloc] init];
    
    int i=0;
    unsigned int mc = 0;
    Method * mlist = class_copyMethodList(object_getClass(t), &mc);
    NSLog(@"%d methods", mc);
    for(i=0;i<mc;i++){
         NSLog(@"Method no #%d: %s", i, sel_getName(method_getName(mlist)));
    }
    [t release]; 


方法二

NSString *className = NSStringFromClass([UIView class]);

    
    const char *cClassName = [className UTF8String];
    
    id theClass = objc_getClass(cClassName);
    
    unsigned int outCount;
    

    Method *m =  class_copyMethodList(theClass,&outCount);
    
    NSLog(@"%d",outCount);
    for (int i = 0; i<outCount; i++) {
        SEL a = method_getName(*(m+1));
        NSString *sn = NSStringFromSelector(a);
        NSLog(@"%@",sn);
    } 

你可能感兴趣的:(可以看到苹果SDK的私有方法)