Skip to content

Instantly share code, notes, and snippets.

@danielgalasko
Last active August 30, 2016 07:58
Show Gist options
  • Save danielgalasko/c648065abb12af9e5d9a to your computer and use it in GitHub Desktop.
Save danielgalasko/c648065abb12af9e5d9a to your computer and use it in GitHub Desktop.
Using dictionaryWithValuesForKeys to get a great object description
- (NSString *)description {
//We list the properties and their values using the ever convenient `dictionaryWithValuesForKeys`
//which will get the values of the corresponding properties
NSDictionary *debugProperties = [self dictionaryWithValuesForKeys:@[NSStringFromSelector(@selector(<#Insert property name#>))]];
return [NSString stringWithFormat:@"<%@: %p> %@", self.class, self, debugProperties];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment