<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Swift on Stay Frosty</title><link>https://frosty.blog/tags/swift/</link><description>Recent content in Swift on Stay Frosty</description><generator>Hugo -- gohugo.io</generator><language>en-gb</language><copyright>© James Frost</copyright><lastBuildDate>Sun, 28 Jul 2019 08:06:19 +0000</lastBuildDate><atom:link href="https://frosty.blog/tags/swift/index.xml" rel="self" type="application/rss+xml"/><item><title>Hacking with Swift: Live!</title><link>https://frosty.blog/2019/07/28/hacking-with-swift-live/</link><pubDate>Sun, 28 Jul 2019 08:06:19 +0000</pubDate><guid>https://frosty.blog/2019/07/28/hacking-with-swift-live/</guid><description>&lt;p&gt;A couple of weeks ago, I attended the first ever &lt;a href="https://www.hackingwithswift.com/live"&gt;Hacking with Swift: Live!&lt;/a&gt; conference in Bath, England. Helpfully, Bath is less than an hour away from where I live so it seemed like a great opportunity to attend a conference while still getting to see my family. And it was fantastic!&lt;/p&gt;
&lt;figure&gt;
 &lt;img src="https://www.hackingwithswift.com/uploads/hws-live.jpg" alt="" loading="lazy"&gt;
&lt;/figure&gt;
&lt;p&gt;If you&amp;rsquo;re not familiar with &lt;a href="Https://www.hackingwithswift.com"&gt;Hacking with Swift&lt;/a&gt;, it&amp;rsquo;s a website run by &lt;a href="https://twitter.com/twostraws"&gt;Paul Hudson&lt;/a&gt;. Paul is a one-man tutorial &lt;em&gt;machine&lt;/em&gt;. I have no idea how he produces so much content. He&amp;rsquo;s written 15 books on Swift and Apple&amp;rsquo;s platforms, and his website contains a &lt;em&gt;ton&lt;/em&gt; of free articles, tutorials, and videos all about Swift. His SwiftUI content has been really helpful, and again I don&amp;rsquo;t know how he created so much of it so soon after WWDC.&lt;/p&gt;</description><content:encoded><![CDATA[<p>A couple of weeks ago, I attended the first ever <a href="https://www.hackingwithswift.com/live">Hacking with Swift: Live!</a> conference in Bath, England. Helpfully, Bath is less than an hour away from where I live so it seemed like a great opportunity to attend a conference while still getting to see my family. And it was fantastic!</p>
<figure>
  <img src="https://www.hackingwithswift.com/uploads/hws-live.jpg" alt="" loading="lazy">
</figure>
<p>If you&rsquo;re not familiar with <a href="Https://www.hackingwithswift.com">Hacking with Swift</a>, it&rsquo;s a website run by <a href="https://twitter.com/twostraws">Paul Hudson</a>. Paul is a one-man tutorial <em>machine</em>. I have no idea how he produces so much content. He&rsquo;s written 15 books on Swift and Apple&rsquo;s platforms, and his website contains a <em>ton</em> of free articles, tutorials, and videos all about Swift. His SwiftUI content has been really helpful, and again I don&rsquo;t know how he created so much of it so soon after WWDC.</p>
<p>Hacking with Swift: Live was Paul&rsquo;s first attempt at running this conference and I think it was a huge success. The venue was modern, clean, and bright, the wifi worked excellently, and the food was really good. There were around 200 attendees which felt like just the right number to me. The format of the event was a little different than other conferences I&rsquo;ve attended before.</p>
<h3 id="day-1">Day 1</h3>
<p><strong>Day 1</strong> was quite standard conference fare, with 8 talks from some fantastic speakers: Cory Benfield (Apple), Kelly Hutchinson, Kilo Loco, Ellen Shapiro, Sally Shepard, Daniel Steinberg, John Sundell, and James Thomson. I particularly enjoyed:</p>
<ul>
<li>Cory&rsquo;s explanation of an easy place to get caught out in terms of performance with Swift&rsquo;s copy-on-write behaviour.</li>
<li>Ellen&rsquo;s talk about the Swift package manager, and using Swift scripts and tools to improve your development life.</li>
<li>Daniel&rsquo;s talk, which cleverly walked through a SwiftUI example by calling out which Swift Evolution proposals were responsible for which pieces of syntax, and explained how they worked.</li>
<li>James&rsquo;s history of easter eggs in Apple&rsquo;s software.</li>
</ul>
<p>But they were all great! The videos are all available on YouTube, and you can find links in <a href="https://www.hackingwithswift.com/articles/197/hacking-with-swift-live-2019-raises-30-000-for-charity">this post on hackingwithswift.com</a>.</p>
<h3 id="day-2">Day 2</h3>
<p><strong>Day 2</strong> was one big workshop. Paul literally <em>wrote a book</em> just for the conference, with 3 large example apps covering most of the big iOS 13 features. We then spent the day following along on our laptops as he led us through each tutorial. It was great to get a chunk of dedicated time working through a real example using the new features.</p>
<div class="gallery">
<figure>
  <a href="/images/2019/07/img_5053.jpeg"><img src="/images/2019/07/img_5053-1600.jpeg" alt="" loading="lazy"></a>
</figure>
<figure>
  <a href="/images/2019/07/img_5054.jpeg"><img src="/images/2019/07/img_5054-1600.jpeg" alt="" loading="lazy"></a>
</figure>
</div>
<p>I particularly enjoyed the morning, which was all SwiftUI. I have to say I have been somewhat skeptical about SwiftUI up until this point (these kids and their new-fangled technologies, what&rsquo;s wrong with the way we do it now? grumble mumble), but using it for a couple of hours&hellip; <strong>wow</strong> is it quick and convenient to build a UI and preview it.</p>
<figure>
  <a href="/images/2019/07/simulator-screen-shot-iphone-xca80-2019-07-10-at-17.18.42.png"><img src="/images/2019/07/simulator-screen-shot-iphone-xca80-2019-07-10-at-17.18.42-1600.png" alt="" loading="lazy"></a>
  <figcaption><p>The SwiftUI demo app we built</p></figcaption>
</figure>
<p>The other standout new pieces of API were diffable data sources (they clean up so much code!) and compositional collection view layouts.</p>
<h3 id="a-good-cause">A good cause</h3>
<p>All of the proceeds from Hacking with Swift: Live went to charity. The conference supported <a href="https://www.specialeffect.org.uk">Special Effect</a>, a charity that &ldquo;puts fun and inclusion back into the lives of people with physical disabilities by helping them to play video games&rdquo;. It seemed like a great cause, and the conference was able to donate $30,000!</p>
<h3 id="summary">Summary</h3>
<p>Paul ended the conference by talking about &rsquo;the bigger picture&rsquo;. How code brought us all together, but it&rsquo;s not the most important thing in any of our lives, and how we should think about the difference we can all make in the wider world. He also said how proud he was to bring everybody together to his home town, and brought his family onstage to say they were his reason for doing everything he does. I may have cried a little 😅.</p>
<p>I really enjoyed the event and felt like it could&rsquo;ve easily been a few days longer (although just two days was quite nice as it limited time away from home). I&rsquo;m keen to go back next year if they hold it again!</p>
]]></content:encoded></item><item><title>Two Nifty Swift Loop Tricks</title><link>https://frosty.blog/2016/02/06/two-nifty-swift-loop-tricks/</link><pubDate>Sat, 06 Feb 2016 19:49:56 +0000</pubDate><guid>https://frosty.blog/2016/02/06/two-nifty-swift-loop-tricks/</guid><description>&lt;p&gt;This week, I learnt two things about Swift that I&amp;rsquo;d never come across before. Both involve loops.&lt;/p&gt;
&lt;p&gt;The first, via &lt;a href="http://ericasadun.com/2016/01/15/3-simple-for-in-iteration-tricks/"&gt;Erica Sadun&lt;/a&gt;: you can use &lt;code&gt;case let&lt;/code&gt; in a &lt;code&gt;for&lt;/code&gt; loop to conditionally bind optionals or cast items. Here&amp;rsquo;s the optional binding example from Erica&amp;rsquo;s post:&lt;/p&gt;





&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-swift" data-lang="swift"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;items&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="p"&gt;?]&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="kc"&gt;nil&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;nil&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;&amp;#34;Hello&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;nil&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;&amp;#34;World&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;item&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;items&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="bp"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Check out the full post, &lt;a href="http://ericasadun.com/2016/01/15/3-simple-for-in-iteration-tricks/"&gt;3 simple for-in iteration tricks&lt;/a&gt; for some other neat tricks.&lt;/p&gt;
&lt;p&gt;Secondly, from &lt;a href="http://krakendev.io/blog/hipster-swift#loop-labels"&gt;this post&lt;/a&gt; at KrakenDev: you can &lt;strong&gt;label loops&lt;/strong&gt; in Swift! Here&amp;rsquo;s an example:&lt;/p&gt;</description><content:encoded><![CDATA[<p>This week, I learnt two things about Swift that I&rsquo;d never come across before. Both involve loops.</p>
<p>The first, via <a href="http://ericasadun.com/2016/01/15/3-simple-for-in-iteration-tricks/">Erica Sadun</a>: you can use <code>case let</code> in a <code>for</code> loop to conditionally bind optionals or cast items. Here&rsquo;s the optional binding example from Erica&rsquo;s post:</p>





<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-swift" data-lang="swift"><span class="line"><span class="cl"><span class="kd">let</span> <span class="nv">items</span><span class="p">:</span> <span class="p">[</span><span class="nb">String</span><span class="p">?]</span> <span class="p">=</span> <span class="p">[</span><span class="kc">nil</span><span class="p">,</span> <span class="kc">nil</span><span class="p">,</span> <span class="s">&#34;Hello&#34;</span><span class="p">,</span> <span class="kc">nil</span><span class="p">,</span> <span class="s">&#34;World&#34;</span><span class="p">]</span>
</span></span><span class="line"><span class="cl"><span class="k">for</span> <span class="k">case</span> <span class="kd">let</span> <span class="nv">item</span><span class="p">?</span> <span class="k">in</span> <span class="n">items</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">    <span class="bp">print</span><span class="p">(</span><span class="n">item</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span></span></span></code></pre></div><p>Check out the full post, <a href="http://ericasadun.com/2016/01/15/3-simple-for-in-iteration-tricks/">3 simple for-in iteration tricks</a> for some other neat tricks.</p>
<p>Secondly, from <a href="http://krakendev.io/blog/hipster-swift#loop-labels">this post</a> at KrakenDev: you can <strong>label loops</strong> in Swift! Here&rsquo;s an example:</p>





<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-swift" data-lang="swift"><span class="line"><span class="cl"><span class="n">sectionLoop</span><span class="p">:</span> <span class="k">for</span> <span class="n">section</span> <span class="k">in</span> <span class="n">sections</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">    <span class="n">rowLoop</span><span class="p">:</span> <span class="k">for</span> <span class="n">row</span> <span class="k">in</span> <span class="n">rows</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">        <span class="k">if</span> <span class="n">row</span><span class="p">.</span><span class="n">isMagical</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">            <span class="k">break</span> <span class="n">sectionLoop</span>
</span></span><span class="line"><span class="cl">        <span class="p">}</span>
</span></span><span class="line"><span class="cl">    <span class="p">}</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span></span></span></code></pre></div><p>Who knew?! There are a bunch more useful tips in the full post, <a href="http://krakendev.io/blog/hipster-swift">Hipster Swift</a>, including descriptions of what <code>@noescape</code> and <code>@autoclosure</code> actually do.</p>
]]></content:encoded></item></channel></rss>