{"id":10660,"date":"2015-02-01T19:27:18","date_gmt":"2015-02-02T00:27:18","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=10660"},"modified":"2016-02-12T14:20:07","modified_gmt":"2016-02-12T19:20:07","slug":"swift-the-objective-c-runtime","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2015\/02\/01\/swift-the-objective-c-runtime\/","title":{"rendered":"Swift &#038; the Objective-C Runtime"},"content":{"rendered":"<p><a href=\"http:\/\/nshipster.com\/swift-objc-runtime\/\">Nate Cook<\/a>:<\/p>\r\n<blockquote cite=\"http:\/\/nshipster.com\/swift-objc-runtime\/\">\r\n<p>Unfortunately, a <code>load<\/code> class method implemented in Swift is <em>never<\/em> called by the runtime, rendering that recommendation an impossibility. Instead, we&rsquo;re left to pick among second-choice options:<\/p>\r\n<ul>\r\n<li><p>Implement method swizzling in <code>initialize<\/code><br \/>\r\nThis can be done safely, so long as you check the type at execution time and wrap the swizzling in <code>dispatch_once<\/code> (which you should be doing anyway).<\/p><\/li>\r\n<li><p>Implement method swizzling in the app delegate<\/p><\/li>\r\n<\/ul>\r\n<\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Nate Cook: Unfortunately, a load class method implemented in Swift is never called by the runtime, rendering that recommendation an impossibility. Instead, we&rsquo;re left to pick among second-choice options: Implement method swizzling in initialize This can be done safely, so long as you check the type at execution time and wrap the swizzling in dispatch_once [&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":[69,31,30,760,71,901],"class_list":["post-10660","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-cocoa","tag-ios","tag-mac","tag-objective-c-runtime","tag-programming","tag-swift-programming-language"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/10660","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=10660"}],"version-history":[{"count":2,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/10660\/revisions"}],"predecessor-version":[{"id":13534,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/10660\/revisions\/13534"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=10660"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=10660"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=10660"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}