{"id":36603,"date":"2022-07-27T17:12:44","date_gmt":"2022-07-27T21:12:44","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=36603"},"modified":"2022-07-27T17:12:44","modified_gmt":"2022-07-27T21:12:44","slug":"swift-tuple-overloads","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2022\/07\/27\/swift-tuple-overloads\/","title":{"rendered":"Swift Tuple Overloads"},"content":{"rendered":"<p><a href=\"https:\/\/twitter.com\/NovallSwift\/status\/1534342577956212737\">Novall Swift<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/NovallSwift\/status\/1534342577956212737\">\n<p>Did you know with WeatherKit you can request any combination of data sets and it&rsquo;s returned as a tuple?<\/p>\n<p>This is great if you only need a subset of data!<\/p>\n<p>Here I&rsquo;m requesting to include the current weather and daily forecast, and I can extract just what I need.<\/p>\n<p>[&#8230;]<\/p>\n<pre>let (current, daily) = try await WeatherService.shared.weather(for: location, including: .current, .daily)<\/pre>\n<\/blockquote>\n\n<p><a href=\"https:\/\/twitter.com\/Freerunnering\/status\/1534348840832204801\">Kyle Howells<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/Freerunnering\/status\/1534348840832204801\">\n<p>How is it doing this for 2,3+ items?<\/p>\n<p>By just having 8 copies of the same method defined!\nWhich also means 8 is props is your max.<\/p>\n<p>[&#8230;]<\/p>\n<p>If this sort of thing is something we are going to be living with for a while, then Apple needs to build in some sort of automatic coalescing into the documentation and Xcode auto complete because this is a very messy and confusing documentation experience.<\/p>\n<\/blockquote>\n\n<p>Perhaps someday Swift will support variadic generics.<\/p>\n\n<p>Previously:<\/p>\n<ul>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2022\/06\/08\/weatherkit\/\">WeatherKit<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2021\/11\/02\/dangerous-nslog-calls-in-swift\/\">Dangerous NSLog() Calls in Swift<\/a><\/li>\n<\/ul>","protected":false},"excerpt":{"rendered":"<p>Novall Swift: Did you know with WeatherKit you can request any combination of data sets and it&rsquo;s returned as a tuple? This is great if you only need a subset of data! Here I&rsquo;m requesting to include the current weather and daily forecast, and I can extract just what I need. [&#8230;] let (current, daily) [&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":"2022-07-27T21:12:47Z","apple_news_api_id":"5f018982-e0e1-4038-8f5a-6fb22080f5e5","apple_news_api_modified_at":"2022-07-27T21:12:48Z","apple_news_api_revision":"AAAAAAAAAAD\/\/\/\/\/\/\/\/\/\/w==","apple_news_api_share_url":"https:\/\/apple.news\/AXwGJguDhQDiPWm-yIID15Q","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":[164,2185,46,30,2223,71,901,2227],"class_list":["post-36603","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-documentation","tag-ios-16","tag-languagedesign","tag-mac","tag-macos-13-ventura","tag-programming","tag-swift-programming-language","tag-weatherkit"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/36603","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=36603"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/36603\/revisions"}],"predecessor-version":[{"id":36604,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/36603\/revisions\/36604"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=36603"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=36603"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=36603"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}