Debug Printing in Swift
For
debugPrint()
… Things look a little bit different. Its output is strikingly similar to theprint()
, but it has a fully qualified print out.[…]
However, if the type doesn’t conform to [
CustomDebugStringConvertible
] - thenString(reflecting:)
dips down intoCustomStringConvertible
, which you’ve likely used in your Swift adventures.[…]
For
Mirror(reflecting:)
This one is quite easy to understand, but can be incredibly useful. In short, you’re getting an instance’s type information.[…]
Using
dump
you can print out entire class hierarchies and type information. In short, it gives you all the freakin’ information it can find about whatever you pass to it.