Skip to content

Instantly share code, notes, and snippets.

@almas73
Created October 27, 2017 00:22
Show Gist options
  • Save almas73/13da3bb2ddcca5a311148e5fddb79479 to your computer and use it in GitHub Desktop.
Save almas73/13da3bb2ddcca5a311148e5fddb79479 to your computer and use it in GitHub Desktop.
@interface NSObject (logProperties)
- (void) logProperties;
@end
#import <objc/runtime.h>
@implementation NSObject (logProperties)
- (void) logProperties {
NSLog(@"----------------------------------------------- Properties for object %@", self);
@autoreleasepool {
unsigned int numberOfProperties = 0;
objc_property_t *propertyArray = class_copyPropertyList([self class], &numberOfProperties);
for (NSUInteger i = 0; i < numberOfProperties; i++) {
objc_property_t property = propertyArray[i];
NSString *name = [[NSString alloc] initWithUTF8String:property_getName(property)];
NSLog(@"Property %@ Value: %@", name, [self valueForKey:name]);
}
free(propertyArray);
}
NSLog(@"-----------------------------------------------");
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment