/**
* 对象转换为字典
*
* @param obj 需要转化的对象
*
* @return 转换后的字典
*/
+ (NSDictionary*)getObjectData:(id)obj {
NSMutableDictionary *dic = [NSMutableDictionary dictionary];
unsigned int propsCount;
objc_property_t *props = class_copyPropertyList([obj class], &propsCount);
for(int i = 0;i < propsCount; i++) {
objc_property_t prop = props[i];
NSString *propName = [NSString stringWithUTF8String:property_getName(prop)];
iOS 对象转换成字典
最新推荐文章于 2022-02-14 11:50:05 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)