https://github.com/niklasberglund/nsobject-description
Helps you produce description method output formatted same way as Apple's classes' description output
https://github.com/niklasberglund/nsobject-description
Last synced: 3 months ago
JSON representation
Helps you produce description method output formatted same way as Apple's classes' description output
- Host: GitHub
- URL: https://github.com/niklasberglund/nsobject-description
- Owner: niklasberglund
- License: mit
- Created: 2016-01-25T12:46:51.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-03-06T17:18:23.000Z (over 9 years ago)
- Last Synced: 2025-01-20T02:49:07.673Z (5 months ago)
- Language: Objective-C
- Homepage:
- Size: 3.91 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# NSObject-description
Helps you produce `description` method output formatted same way as Apple's classes' `description` output.# Install
Either manually add the files to your project or install using CocoaPods. Add NSObject+description to your Podfile like so:
```
pod 'NSObject+description'
```# Usage
## Manually pass attribute names and values
Override the class' `- (NSString *)description` method to have it return the *NSString* produced by `- (NSString *)descriptionWithMembers:`. Pass a *NSDictionary* with names and values of your object's attributes to `descriptionWithMembers:` like so:```
- (NSString *)description
{
return [self descriptionWithMembers: @{
@"firstName:": self.firstName,
@"lastName": self.lastName,
@"phoneNumber": phoneNumber
}];
}
```## Automatically fetch attributes
You can have your `- (NSString *)description` method return a *NSString* representation of your class without manually passing the attributes manually like so:
```
- (NSString *)description
{
return [self descriptionWithAllProperties];
}
```