// 获取对象所有属性: - (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; }
时间: 2024-11-06 03:41:58