{"id":1649,"date":"2008-01-02T11:28:13","date_gmt":"2008-01-02T15:28:13","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/2008\/01\/02\/logging-messages-to-nil\/"},"modified":"2008-01-04T10:50:15","modified_gmt":"2008-01-04T14:50:15","slug":"logging-messages-to-nil","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2008\/01\/02\/logging-messages-to-nil\/","title":{"rendered":"Logging Messages to Nil"},"content":{"rendered":"<p><a href=\"http:\/\/www.friday.com\/bbum\/2008\/01\/02\/objective-c-logging-messages-to-nil\/\">Bill Bumgarner<\/a> shows how to use the private <code>_objc_setNilReceiver()<\/code> function and <code>-resolveInstanceMethod:<\/code> to log the first time each selector is sent to <code>nil<\/code>. I imagine that by uncommenting the print statement in <code>-forwardInvocation: <\/code> this could be made to work with Objective-C 1.x, but you&rsquo;d get a log entry for every message sent to <code>nil<\/code>.<\/p>\n<p>Update: Bumgarner shows how to do the logging <a href=\"http:\/\/www.friday.com\/bbum\/2008\/01\/03\/objective-c-using-dtrace-to-trace-messages-to-nil\/\">using Leopard&rsquo;s DTrace<\/a>.<\/p>\n<p>Update 2: How to do it <a href=\"http:\/\/www.friday.com\/bbum\/2008\/01\/04\/objective-c-using-instruments-to-trace-messages-to-nil\/\">with Instruments<\/a>.<\/p>","protected":false},"excerpt":{"rendered":"<p>Bill Bumgarner shows how to use the private _objc_setNilReceiver() function and -resolveInstanceMethod: to log the first time each selector is sent to nil. I imagine that by uncommenting the print statement in -forwardInvocation: this could be made to work with Objective-C 1.x, but you&rsquo;d get a log entry for every message sent to nil. Update: [&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":"","apple_news_api_id":"","apple_news_api_modified_at":"","apple_news_api_revision":"","apple_news_api_share_url":"","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":[],"class_list":["post-1649","post","type-post","status-publish","format-standard","hentry","category-programming-category"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/1649","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=1649"}],"version-history":[{"count":0,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/1649\/revisions"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=1649"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=1649"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=1649"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}