Tuesday, September 27, 2022

Debug Printing in Swift

Jordan Morgan:

For debugPrint()… Things look a little bit different. Its output is strikingly similar to the print(), but it has a fully qualified print out.

[…]

However, if the type doesn’t conform to [CustomDebugStringConvertible] - then String(reflecting:) dips down into CustomStringConvertible, 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.

Comments RSS · Twitter

Leave a Comment