-(NSDictionary *) dictionary{
unsigned int outCount = 0;
objc_property_t *propertyList = class_copyPropertyList([self class], &outCount);
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
for(int i = 0; i < outCount; i++){
objc_property_t property = propertyList[i];
const char * propertyName = property_getName(property);
SEL getter = sel_registerName(propertyName);
if ([self respondsToSelector:getter]) {
NSString *type = [NSString stringWithUTF8String:property_getAttributes(property)];
NSLog(@"type:%@",type);
if ([type hasPrefix:@"Ti"]) {
int value = ((int(*)(id,SEL))objc_msgSend)(self,getter);
NSString *key = [NSString stringWithUTF8String:propertyName];
[dict setObject:[NSNumber numberWithInt:value] forKey:key];
NSLog(@"key:%@,value:%d",key,value);
}else{
id value=((id(*)(id,SEL))objc_msgSend)(self,getter);
if ([value isKindOfClass:[self class]] && value) {
value = [value dictionary];
}
if (value) {
NSString *key = [NSString stringWithUTF8String:propertyName];
[dict setObject:value forKey:key];
NSLog(@"key:%@,value:%@",key,value);
}
}
}
}
return dict;
}