Rodhos Soft

備忘録を兼ねた技術的なメモです。Rofhos SoftではiOSアプリ開発を中心としてAndroid, Webサービス等の開発を承っております。まずはご相談下さい。

クラスダンプ

- (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);