无标题文章

  • (void)initialize
    {
    [self getIvars];
    }

  • (void)getProperties
    {
    unsigned int count = 0;

    objc_property_t *properties = class_copyPropertyList([UITextField class], &count);

    for (int i = 0; i // 取出属性
    objc_property_t property = properties[i];

      // 打印属性名字
      XMGLog(@"%s   <---->   %s", property_getName(property), property_getAttributes(property));
    

    }

    free(properties);
    }

  • (void)getIvars
    {
    unsigned int count = 0;

    // 拷贝出所有的成员变量列表
    Ivar *ivars = class_copyIvarList([UITextField class], &count);

    for (int i = 0; i // 取出成员变量
    // Ivar ivar = *(ivars + i);
    Ivar ivar = ivars[i];

      // 打印成员变量名字
      XMGLog(@"%s %s", ivar_getName(ivar), ivar_getTypeEncoding(ivar));
    

    }

    // 释放
    free(ivars);
    }

    Ivar *ivars = class_copyIvarList([UITextField class], &count);

    for (int i = 0; i // 取出成员变量
    // Ivar ivar = *(ivars + i);
    Ivar ivar = ivars[i];

      // 打印成员变量名字
      XMGLog(@"%s %s", ivar_getName(ivar), ivar_getTypeEncoding(ivar));
    

    }

    // 释放
    free(ivars);
    }

baigif.gif

你可能感兴趣的:(无标题文章)