运行时获取属性列表

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

相关文章
相关标签/搜索