Skip to content

Instantly share code, notes, and snippets.

@fernandodev
Created April 13, 2018 08:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fernandodev/532246d3d7d55a35ce379d9eb628c1f8 to your computer and use it in GitHub Desktop.
Save fernandodev/532246d3d7d55a35ce379d9eb628c1f8 to your computer and use it in GitHub Desktop.
- (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