+(MicroPage*)creatPage:(NSMutableDictionary*)dic
{
//反射 对象赋值
MicroPage *m = [[[MicroPage alloc] init] autorelease];
unsigned int outCount;
objc_property_t *properties = class_copyPropertyList([m class], &outCount);
for (int i=0; i<outCount; i++) {
const char *pName = property_getName(properties[i]);
NSString *propertyName = [NSString stringWithCString:pName encoding:NSUTF8StringEncoding];
id value = [dic objectForKey:propertyName];
[m setValue:value forKey:propertyName];
}
return m;
}
反射 dic转换成对象
最新推荐文章于 2023-09-11 11:03:55 发布