{"id":12404,"date":"2015-09-25T09:47:04","date_gmt":"2015-09-25T13:47:04","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=12404"},"modified":"2015-09-25T09:47:04","modified_gmt":"2015-09-25T13:47:04","slug":"swizzling-with-swift","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2015\/09\/25\/swizzling-with-swift\/","title":{"rendered":"Swizzling With Swift"},"content":{"rendered":"<p><a href=\"https:\/\/realm.io\/news\/sash-zats-swift-swizzling\/\">Sash Zats<\/a>:<\/p>\n<blockquote cite=\"https:\/\/realm.io\/news\/sash-zats-swift-swizzling\/\">\n<p>Another issue I&rsquo;ve yet to mention is how to call the original implementation. In this case, I had no desire to figure out how to re-implement the function, so we have to call the original implementation, and retain the returning object on top. This is a problem with Swift 1.2: you cannot call C functions just through their pointer. To be clear, you can call C functions from Swift, but you cannot obtain pointers to functions using other tools and call the function through its pointer like you would do in Objective-C.<\/p>\n<p>As a result, this part has to be implemented in Objective-C. I am not proud about it, but that&rsquo;s what we have to do for now.<\/p>\n<\/blockquote>\n<p>Swift 2 <a href=\"http:\/\/www.charlessoft.com\/hacks\/using_c_function_pointers_in_swift.html\">does<\/a> <a href=\"https:\/\/www.mikeash.com\/pyblog\/friday-qa-2015-06-19-the-best-of-whats-new-in-swift.html\">support<\/a> calling C function pointers.<\/p>","protected":false},"excerpt":{"rendered":"<p>Sash Zats: Another issue I&rsquo;ve yet to mention is how to call the original implementation. In this case, I had no desire to figure out how to re-implement the function, so we have to call the original implementation, and retain the returning object on top. This is a problem with Swift 1.2: you cannot call [&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":[738,31,30,54,71,901,943],"class_list":["post-12404","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-conference","tag-ios","tag-mac","tag-objective-c","tag-programming","tag-swift-programming-language","tag-swift-runtime"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/12404","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=12404"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/12404\/revisions"}],"predecessor-version":[{"id":12405,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/12404\/revisions\/12405"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=12404"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=12404"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=12404"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}