A default CustomStringConvertible
implementation for Swift types
Never implement var description: String
again. Simply import DefaultStringConvertible
and conform to CustomStringConvertible
and get a default type description for free.
This micro-library is based on this post from Erica Sadun.
- Xcode 7.3+
- iOS 8.0+
- OSX 10.10+
- tvOS 9.0+
- watchOS 2.0+
- Swift 2.2+
CocoaPods (recommended)
use_frameworks!
# For latest release in cocoapods
pod 'DefaultStringConvertible'
# Feeling adventurous? Get the latest on develop
pod 'DefaultStringConvertible', :git => 'https://github.com/jessesquires/DefaultStringConvertible.git', :branch => 'develop'
github "jessesquires/DefaultStringConvertible"
Read the docs. Generated with jazzy. Hosted by GitHub Pages. More information on the gh-pages
branch.
import DefaultStringConvertible
class MyClass: CustomStringConvertible {
// ...
// You *do not* need to implement `var description: String`
// by importing `DefaultStringConvertible`, you get a default `description` for free
}
There's a suite of unit tests for DefaultStringConvertible
. Run them from Xcode by opening DefaultStringConvertible.xcodeproj
. These tests are well commented and serve as further documentation for how to use this library.
Please follow these sweet contribution guidelines.
Created and maintained by @jesse_squires.
DefaultStringConvertible
is released under an MIT License. See LICENSE
for details.
Copyright © 2016-present Jesse Squires.
Please provide attribution, it is greatly appreciated.