{"id":14594,"date":"2016-05-20T10:49:47","date_gmt":"2016-05-20T14:49:47","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=14594"},"modified":"2016-05-20T10:49:47","modified_gmt":"2016-05-20T14:49:47","slug":"testing-iboutlets-and-ibactions-with-curried-functions-in-swift","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2016\/05\/20\/testing-iboutlets-and-ibactions-with-curried-functions-in-swift\/","title":{"rendered":"Testing IBOutlets and IBActions With Curried Functions in Swift"},"content":{"rendered":"<p><a href=\"http:\/\/phatbl.at\/2016\/04\/29\/testing-iboutlets-and-ibactions-with-curried-functions-in-swift.html\">Ben Chatelain<\/a>:<\/p>\n<blockquote cite=\"http:\/\/phatbl.at\/2016\/04\/29\/testing-iboutlets-and-ibactions-with-curried-functions-in-swift.html\">\n<p>Currying helps to simplify these outlet and action test functions so that the view controller doesn&rsquo;t have to be passed in every function call. Just like the <code>sumA<\/code> function holds onto the value of the first parameter, these test functions hold onto a reference to the view controller being tested. There&rsquo;s also the benefit of being able to give the returned function a very readable name.<\/p>\n<p>[&#8230;]<\/p>\n<p>So, what is that <code>hasButtonOutlet<\/code> magic? It&rsquo;s a <a href=\"https:\/\/en.m.wikipedia.org\/wiki\/Partial_application\">partially-applied<\/a> function saved in a local variable.<\/p>\n<p>[&#8230;]<\/p>\n<p>Shortly after <a href=\"https:\/\/twitter.com\/allonsykraken\">@allonsykraken<\/a> posted <a href=\"http:\/\/krakendev.io\/blog\/hipster-swift\">Hipster Swift<\/a>, I learned that the super-clean syntactic sugar version of curried functions is <a href=\"https:\/\/github.com\/apple\/swift-evolution\/blob\/master\/proposals\/0002-remove-currying.md\">going away in Swift 3<\/a> and it made me sad.<\/p><\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Ben Chatelain: Currying helps to simplify these outlet and action test functions so that the view controller doesn&rsquo;t have to be passed in every function call. Just like the sumA function holds onto the value of the first parameter, these test functions hold onto a reference to the view controller being tested. There&rsquo;s also the [&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,71,901,268],"class_list":["post-14594","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-cocoa","tag-ios","tag-mac","tag-programming","tag-swift-programming-language","tag-testing"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/14594","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=14594"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/14594\/revisions"}],"predecessor-version":[{"id":14595,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/14594\/revisions\/14595"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=14594"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=14594"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=14594"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}