Skip to content

Instantly share code, notes, and snippets.

@mwrites
Created June 18, 2019 05:41
Show Gist options
  • Save mwrites/a291367d114123fe79f9d95efdc187ec to your computer and use it in GitHub Desktop.
Save mwrites/a291367d114123fe79f9d95efdc187ec to your computer and use it in GitHub Desktop.
CustomStringConvertible
extension CustomStringConvertible {
var description : String {
var description: String = ""
if self is AnyObject {
description = "***** \(type(of: self)) - <\(unsafeAddressOf((self as! AnyObject)))>***** \n"
} else {
description = "***** \(type(of: self)) *****\n"
}
let selfMirror = String(reflecting: self)
for child in selfMirror.children {
if let propertyName = child.label {
description += "\(propertyName): \(child.value)\n"
}
}
return description
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment