Permalink
Browse files

changed to work with super class. (made class specified method)

  • Loading branch information...
1 parent 90f2f77 commit de732575b895a9b680038b2d239bd27156dd2b5e @tomohisa tomohisa committed Feb 26, 2012
Showing with 9 additions and 1 deletion.
  1. +1 −0 Classes/DescriptionBuilder.h
  2. +8 −1 Classes/DescriptionBuilder.m
@@ -20,5 +20,6 @@ typedef enum DescriptionStyle {
+ (NSString *)reflectDescription:(id)obj;
+ (NSString *)reflectDescription:(id)obj style:(DescriptionStyle)style;
++ (NSString *)reflectDescription:(id)obj style:(DescriptionStyle)style targetClass:(Class)cls;
@end
@@ -37,6 +37,9 @@ + (NSString *)reflectDescription:(id)obj {
{ 構造体
*/
+ (NSString *)reflectDescription:(id)obj style:(DescriptionStyle)style {
+ return [DescriptionBuilder reflectDescription:obj style:style targetClass:[obj class]];
+}
++ (NSString *)reflectDescription:(id)obj style:(DescriptionStyle)style targetClass:(Class)cls{
id objValue;
Class classValue;
SEL selValue;
@@ -57,7 +60,7 @@ + (NSString *)reflectDescription:(id)obj style:(DescriptionStyle)style {
NSMutableString *description = [[[NSMutableString alloc] init] autorelease];
- Class clazz = [obj class];
+ Class clazz = cls;
unsigned int outCount = 0;
Ivar *ivars = class_copyIvarList(clazz, &outCount);
@@ -230,6 +233,10 @@ + (NSString *)reflectDescription:(id)obj style:(DescriptionStyle)style {
break;
}
}
+ if (class_getSuperclass(cls)) {
+ [description appendString:@"\n"];
+ [description appendString:[DescriptionBuilder reflectDescription:obj style:style targetClass:class_getSuperclass(cls)]];
+ }
[description appendString:@">"];
if (outCount > 0) { free(ivars); }
return description;

0 comments on commit de73257

Please sign in to comment.