Created
February 22, 2011 20:42
-
-
Save rbsgn/839349 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
@interface NSObject (YXDebug) | |
- (NSString *)yx_description; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "NSObject-Verbose.h" | |
#import <objc/runtime.h> | |
@implementation NSObject (YXDebug) | |
- (NSString *)yx_description { | |
unsigned int count = 0; | |
objc_property_t * properties = class_copyPropertyList([self class], &count); | |
NSMutableString * result = [[NSMutableString alloc] init]; | |
[result appendFormat:@"<%@: %p> {\n", NSStringFromClass([self class]), self]; | |
for (unsigned int i = 0; i < count; i++) { | |
NSString * name = [NSString stringWithUTF8String:property_getName(properties[i])]; | |
id value = [self valueForKey:name]; | |
[result appendFormat:@"%@ - %@,\n", name, [value description]]; | |
} | |
[result appendString:@"}\n"]; | |
if (properties != NULL) { | |
free(properties); | |
} | |
return [result autorelease]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
u need to free properties!