Created
April 13, 2018 08:13
-
-
Save fernandodev/532246d3d7d55a35ce379d9eb628c1f8 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
- (void)logPropertiesFromObject:(id)object { | |
NSLog(@"----------------------------------------------- Properties for object %@", object); | |
NSMutableString *result = [@"{\n" mutableCopy]; | |
@autoreleasepool { | |
unsigned int numberOfProperties = 0; | |
objc_property_t *propertyArray = class_copyPropertyList([object class], &numberOfProperties); | |
for (NSUInteger i = 0; i < numberOfProperties; i++) { | |
objc_property_t property = propertyArray[i]; | |
NSString *name = [[NSString alloc] initWithUTF8String:property_getName(property)]; | |
[result appendFormat:@"%@: %@\n", name, [object valueForKey:name]]; | |
} | |
free(propertyArray); | |
} | |
[result appendString:@"}\n"]; | |
NSLog(@"%@", result); | |
NSLog(@"-----------------------------------------------"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment