{"id":8835,"date":"2014-05-19T23:00:11","date_gmt":"2014-05-20T03:00:11","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=8835"},"modified":"2014-05-19T23:00:12","modified_gmt":"2014-05-20T03:00:12","slug":"extended-type-info-in-objective-c","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2014\/05\/19\/extended-type-info-in-objective-c\/","title":{"rendered":"Extended Type Info in Objective-C"},"content":{"rendered":"<p><a href=\"http:\/\/bou.io\/ExtendedTypeInfoInObjC.html\">Nicolas Bouilleaud<\/a>:<\/p>\n<blockquote cite=\"http:\/\/bou.io\/ExtendedTypeInfoInObjC.html\"><p>What? Nil objects don&rsquo;t have a class; they&rsquo;re just nil pointers. <code>_ivarDescription<\/code> prints the <em>expected<\/em> class of the instance variable, as specified in the source code.<\/p>\n<p>In fact, <strong>the compiler stores extended type info in the binary<\/strong>. That&rsquo;s really weird: Objective-C treats all objects equals, as <code>id<\/code>s, and will not complain when assigning an object of a class to a pointer of a different type. I always assumed that class info was lost at runtime; it turns out that&rsquo;s not true.<\/p>\n<p>[&#8230;]<\/p>\n<p>As with ivars, methods arguments expect objects of a specific class, and this information is embedded in the binary. For some reason, it&rsquo;s only available for methods declared in Protocols, and the public runtime API won&rsquo;t let us access it, but the private function <code>_protocol_getMethodTypeEncoding()<\/code> will do.<\/p>\n<\/blockquote>\n<p>Maybe someday the runtime will be able to access annotations, too&#8230;<\/p>","protected":false},"excerpt":{"rendered":"<p>Nicolas Bouilleaud: What? Nil objects don&rsquo;t have a class; they&rsquo;re just nil pointers. _ivarDescription prints the expected class of the instance variable, as specified in the source code. In fact, the compiler stores extended type info in the binary. That&rsquo;s really weird: Objective-C treats all objects equals, as ids, and will not complain when assigning [&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":[31,30,54,760,71],"class_list":["post-8835","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-ios","tag-mac","tag-objective-c","tag-objective-c-runtime","tag-programming"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/8835","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=8835"}],"version-history":[{"count":0,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/8835\/revisions"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=8835"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=8835"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=8835"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}