{"id":37165,"date":"2022-09-27T16:52:22","date_gmt":"2022-09-27T20:52:22","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=37165"},"modified":"2022-09-27T16:52:22","modified_gmt":"2022-09-27T20:52:22","slug":"debug-printing-in-swift","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2022\/09\/27\/debug-printing-in-swift\/","title":{"rendered":"Debug Printing in Swift"},"content":{"rendered":"<p><a href=\"https:\/\/www.swiftjectivec.com\/swift-debug-print-print-dump-mirror-reflection\/\">Jordan Morgan<\/a>:<\/p>\n<blockquote cite=\"https:\/\/www.swiftjectivec.com\/swift-debug-print-print-dump-mirror-reflection\/\"><p>For <code>debugPrint()<\/code>&#8230;\nThings look a <em>little<\/em> bit different. Its output is strikingly similar to the <code>print()<\/code>, but it has a fully qualified print out.<\/p><p>[&#8230;]<\/p><p>However, if the type doesn&rsquo;t conform to [<code>CustomDebugStringConvertible<\/code>] - then <code>String(reflecting:)<\/code> dips down into <code>CustomStringConvertible<\/code>, which you&rsquo;ve likely used in your Swift adventures.<\/p><p>[&#8230;]<\/p><p>For <code>Mirror(reflecting:)<\/code>\nThis one is quite easy to understand, but can be incredibly useful. In short, you&rsquo;re getting an instance&rsquo;s type information.<\/p><p>[&#8230;]<\/p><p>Using <code>dump<\/code> you can print out entire class hierarchies and type information. In short, it gives you <em>all<\/em> the freakin&rsquo; information it can find about whatever you pass to it.<\/p><\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Jordan Morgan: For debugPrint()&#8230; Things look a little bit different. Its output is strikingly similar to the print(), but it has a fully qualified print out.[&#8230;]However, if the type doesn&rsquo;t conform to [CustomDebugStringConvertible] - then String(reflecting:) dips down into CustomStringConvertible, which you&rsquo;ve likely used in your Swift adventures.[&#8230;]For Mirror(reflecting:) This one is quite easy to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"2022-09-27T20:52:25Z","apple_news_api_id":"eb402f8f-af0e-4ac0-885b-ee332d447423","apple_news_api_modified_at":"2022-09-27T20:52:25Z","apple_news_api_revision":"AAAAAAAAAAD\/\/\/\/\/\/\/\/\/\/w==","apple_news_api_share_url":"https:\/\/apple.news\/A60Avj68OSsCIW-4zLUR0Iw","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[56,31,2185,30,2077,71,901],"class_list":["post-37165","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-debugging","tag-ios","tag-ios-16","tag-mac","tag-macos-12","tag-programming","tag-swift-programming-language"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/37165","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=37165"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/37165\/revisions"}],"predecessor-version":[{"id":37166,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/37165\/revisions\/37166"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=37165"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=37165"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=37165"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}