Created
October 27, 2017 00:22
-
-
Save almas73/13da3bb2ddcca5a311148e5fddb79479 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
@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