読者です 読者をやめる 読者になる 読者になる

Rodhos Soft

備忘録を兼ねた技術的なメモです。

クラスダンプ

- (void)dampClass:(Class)c
{
    NSString *clasName = NSStringFromClass(c);
    NSLog(@"%@", clasName);
    
    NSLog(@"method");
    {
        unsigned int count = 0;
        Method *methodList = class_copyMethodList(c, &count);
        NSMutableString *m = [NSMutableString string];
        for (int i = 0; i < count; i++) {
            Method method = methodList[i];
            NSString *d = [NSString stringWithFormat:@"%s, %s \n", sel_getName(method_getName(method)), method_getTypeEncoding(method)];
            [m appendString:d];
        }
        NSLog(@"%@", m);
        free(methodList);
    }

    NSLog(@"vars");
    {
        unsigned count;
        Ivar *ivars = class_copyIvarList(c, &count);
        
        NSMutableString *m = [NSMutableString string];
        for(int i = 0 ; i < count ; ++i) {
            Ivar ivar = ivars[i];
            
            NSString *d = [NSString stringWithFormat:@"%s, %s \n", ivar_getName(ivar), ivar_getTypeEncoding(ivar)];
            [m appendString:d];
        }
        
        NSLog(@"%@", m);
        free(ivars);
    }
}

    NSLog(@"%@", m);
広告を非表示にする