// 获取对象所有属性:

- (NSArray*)propertyKeys

{

    unsigned int outCount, i;

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

    NSMutableArray *keys = [[NSMutableArray alloc] initWithCapacity:outCount];

    for (i = 0; i < outCount; i++) {

        objc_property_t property = properties[i];

        NSString *propertyName = [[NSString alloc] initWithCString:property_getName(property) encoding:NSUTF8StringEncoding];

        [keys addObject:propertyName];

    }

    free(properties);

    return keys;

}

 

相关文章:

  • 2022-01-03
  • 2022-12-23
  • 2021-08-05
  • 2022-12-23
  • 2022-12-23
  • 2021-11-21
  • 2021-08-21
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-01
  • 2022-12-23
  • 2021-08-14
  • 2022-12-23
相关资源
相似解决方案