Last active
August 29, 2015 13:58
-
-
Save Broich/10261779 to your computer and use it in GitHub Desktop.
This file contains hidden or 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+Log.h" | |
#import <objc/runtime.h> | |
@implementation NSObject (Log) | |
- (void)log:(id)logObject | |
{ | |
unsigned int numberOfProperties = 0; | |
objc_property_t *propertyArray = class_copyPropertyList([logObject class], &numberOfProperties); | |
NSLog(@"Property List for: %@", NSStringFromClass([self class])); | |
for (int i = 0; i < numberOfProperties; i++) { | |
objc_property_t property = propertyArray[i]; | |
NSString *name = [[NSString alloc] initWithUTF8String:property_getName(property)]; | |
id value = [self valueForKey:name]; | |
NSLog(@"%@: %@", name, value); | |
} | |
free(propertyArray); | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment