{"id":12027,"date":"2015-08-19T10:17:51","date_gmt":"2015-08-19T14:17:51","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=12027"},"modified":"2015-08-19T10:17:51","modified_gmt":"2015-08-19T14:17:51","slug":"generic-functions-in-objective-c","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2015\/08\/19\/generic-functions-in-objective-c\/","title":{"rendered":"Generic &ldquo;Functions&rdquo; in Objective-C"},"content":{"rendered":"<p><a href=\"http:\/\/holko.pl\/2015\/08\/10\/generic-functions\/\">Arkadiusz Holko<\/a>:<\/p>\n<blockquote cite=\"http:\/\/holko.pl\/2015\/08\/10\/generic-functions\/\">\n<p>Since the only way to declare generic parameters and return values is through a class interface, we&rsquo;ll wrap our map method in a new class[&#8230;]<\/p>\n<p>[&#8230;]<\/p>\n<p><code>AHKArrayMapper&rsquo;s<\/code> only method takes an array of <code>InputType<\/code> objects and a block mapping from <code>InputType<\/code> to <code>OutputType<\/code>. It returns an array of <code>OutputType<\/code> objects.\nThe implementation doesn&rsquo;t really differ from the one without generics, because generics <a href=\"http:\/\/drekka.ghost.io\/objective-c-generics\/#thegenericsappledidntmention\">aren&rsquo;t available in implementation files<\/a>[&#8230;]<\/p>\n<\/blockquote>\n<p>Objective-C generics are useful for interfacing with Swift and for documenting APIs. I&rsquo;m not sure that it really makes sense to code with them this way.<\/p>","protected":false},"excerpt":{"rendered":"<p>Arkadiusz Holko: Since the only way to declare generic parameters and return values is through a class interface, we&rsquo;ll wrap our map method in a new class[&#8230;] [&#8230;] AHKArrayMapper&rsquo;s only method takes an array of InputType objects and a block mapping from InputType to OutputType. It returns an array of OutputType objects. The implementation doesn&rsquo;t [&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,46,30,54,71],"class_list":["post-12027","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-cocoa","tag-ios","tag-languagedesign","tag-mac","tag-objective-c","tag-programming"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/12027","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=12027"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/12027\/revisions"}],"predecessor-version":[{"id":12028,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/12027\/revisions\/12028"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=12027"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=12027"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=12027"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}