Skip to content

Instantly share code, notes, and snippets.

@Broich
Last active August 29, 2015 13:58
Show Gist options
  • Save Broich/10261779 to your computer and use it in GitHub Desktop.
Save Broich/10261779 to your computer and use it in GitHub Desktop.
#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