运行时获取属性列表

来源:互联网 发布:新碧粉色防晒知乎 编辑:程序博客网 时间:2024/05/15 15:31

#import <objc/runtime.h>



    unsigned int count;

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

    for (int i =0; i<count; i++) {

        objc_property_t property = properties[i];

        

        NSLog(@"name:%s",property_getName(property));

        NSLog(@"attributes:%s",property_getAttributes(property));

    }

    free(properties);


0 0