获得一个类的所有属性

- (NSArray *)getPropertyListByClass: (Class)clazz
{
    u_int count;
   
    objc_property_t *properties  = class_copyPropertyList(clazz, &count);
   
    NSMutableArray *propertyArray = [NSMutableArray arrayWithCapacity:count];
   
    for (int i = 0; i < count ; i++)
    {
        const char* propertyName = property_getName(properties[i]);
        [propertyArray addObject: [NSString  stringWithUTF8String: propertyName]];
    }
   
    free(properties);
   
    return propertyArray;
}
 

你可能感兴趣的:(职场,iPhone,属性,休闲)