<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Andy Lawler</title>
    <description>The latest articles on DEV Community by Andy Lawler (@andylawler).</description>
    <link>https://dev.to/andylawler</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F157221%2Fb7eeff24-c665-496a-b258-cf4b7d58b92f.png</url>
      <title>DEV Community: Andy Lawler</title>
      <link>https://dev.to/andylawler</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/andylawler"/>
    <language>en</language>
    <item>
      <title>Back after 6 years: my SwiftLeeds 2026 best bits 🎤</title>
      <dc:creator>Andy Lawler</dc:creator>
      <pubDate>Sat, 17 Oct 2026 20:08:34 +0000</pubDate>
      <link>https://dev.to/andylawler/back-after-6-years-my-swiftleeds-2026-best-bits-2687</link>
      <guid>https://dev.to/andylawler/back-after-6-years-my-swiftleeds-2026-best-bits-2687</guid>
      <description>&lt;p&gt;Hi! 👋🏻 I'm Andy. It's been over 6 years now since I last wrote on this blog, it baffles me too that it's been that long... When I started writing here I was just a university student who had found iOS development and started doing tons and tons of YouTube tutorials and courses (shoutout to Sean Allen for those). Over time I felt like I learned something and I wanted to share it with others.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fpsb64ca4luxd0be8xoju.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fpsb64ca4luxd0be8xoju.png" alt="My profile picture" width="268" height="268"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  📍 Where have I been?
&lt;/h2&gt;

&lt;p&gt;After a short while of learning iOS on my own, I wanted to at least see what the real world of work was like so I began spending my free-time at an app agency, this let me see how teams functioned and what a real working environment was like. Off the back of that, I managed to get a placement year during my degree working for Jigsaw which at the time was a dating app based in Manchester.&lt;/p&gt;

&lt;p&gt;This was my first real insight into what working on a real app was like. I managed to work on and ship my own features, test releases and really feel part of a team.&lt;/p&gt;

&lt;p&gt;After going back to university and finishing my degree, I then moved on to work for Sky Bet in Leeds. There I worked on the main Sky Bet iOS app each day, building things like the dynamic content system to show different things on the home screen to users and then later became quite a key part in a huge migration to a brand new Sky Bet app which saw us re-do 70% of the app.&lt;/p&gt;

&lt;p&gt;That was quite a challenge and I definitely wanted to try something new after that experience, so now I'm working at Depop as part of the Better Matching Experience team. Here I get to work daily on improving the experience for our users on the home, discover, search screens and much more. Enough about me anyway... why am I back?&lt;/p&gt;

&lt;p&gt;Well, I just attended the SwiftLeeds iOS conference for a whopping 6th time. Yes, you read that right, 6th time. It left me with the motivation to share and that's what has led me to revive this blog. So without further ado, here is a little round-up of the conference, my favourite bits and some takeaways.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fo7uy9z4qfsr37jo0iodj.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fo7uy9z4qfsr37jo0iodj.jpg" alt="Boarding pass number six" width="800" height="1067"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Boarding pass number six. ✈️&lt;/em&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  🏆 My two favourite talks
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Delightful Text-Driven Experiences with SwiftUI's TextRenderer (&lt;a href="https://eliperkins.com" rel="noopener noreferrer"&gt;Eli Perkins&lt;/a&gt;)
&lt;/h3&gt;

&lt;p&gt;Eli works on &lt;a href="https://apps.apple.com/us/app/particle-personalized-news/id6683283775" rel="noopener noreferrer"&gt;Particle&lt;/a&gt; and showed how SwiftUI's &lt;a href="https://developer.apple.com/documentation/swiftui/textrenderer" rel="noopener noreferrer"&gt;&lt;code&gt;TextRenderer&lt;/code&gt;&lt;/a&gt; lets you bring your text to life and really delight your users. Eli's talk made me realise that we often think about animating our screens and creating interesting things for our users, but I don't often consider doing the same with the text as well.&lt;/p&gt;

&lt;p&gt;So how do text renderers work and how do we use one? Well first, to use them you can add the &lt;code&gt;.textRenderer&lt;/code&gt; modifier to your text, passing in a renderer.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight swift"&gt;&lt;code&gt;&lt;span class="kt"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Hello, World!"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;textRenderer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;Passthrough&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To create a renderer, you conform your struct to the &lt;code&gt;TextRenderer&lt;/code&gt; protocol and implement &lt;code&gt;draw(layout:in:)&lt;/code&gt;. The simplest one just draws every line as normal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight swift"&gt;&lt;code&gt;&lt;span class="kd"&gt;struct&lt;/span&gt; &lt;span class="kt"&gt;Passthrough&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;TextRenderer&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;func&lt;/span&gt; &lt;span class="nf"&gt;draw&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;layout&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;Text&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="kt"&gt;Layout&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nv"&gt;context&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;inout&lt;/span&gt; &lt;span class="kt"&gt;GraphicsContext&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;layout&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;draw&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;line&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="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;SwiftUI hands your renderer the text broken into lines, and each line into runs. A run is a chunk of the line that's styled differently from the text around it, so a bold word or an inline icon, for example, ends up in its own run. Inside each run are the glyphs: every letter, space and punctuation mark.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ffxy73x29olsyvn8savx0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ffxy73x29olsyvn8savx0.png" alt="How renderers work" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can apply operations like opacity and colour to any of those levels, and group them, much like you would with images. Every &lt;code&gt;TextRenderer&lt;/code&gt; is also &lt;code&gt;Animatable&lt;/code&gt;, so if you add an &lt;code&gt;animatableData&lt;/code&gt; property and animate it, you can reveal text line by line or glyph by glyph.&lt;/p&gt;

&lt;p&gt;Here's a quick example of that. This renderer fades each glyph in and slides it up into place, one after the other:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight swift"&gt;&lt;code&gt;&lt;span class="kd"&gt;struct&lt;/span&gt; &lt;span class="kt"&gt;AppearRenderer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;TextRenderer&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="nv"&gt;progress&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;Double&lt;/span&gt;

    &lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="nv"&gt;animatableData&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;Double&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;get&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;progress&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="k"&gt;set&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;progress&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;newValue&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;func&lt;/span&gt; &lt;span class="nf"&gt;draw&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;layout&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;Text&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="kt"&gt;Layout&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nv"&gt;context&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;inout&lt;/span&gt; &lt;span class="kt"&gt;GraphicsContext&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// Lines → runs → glyphs&lt;/span&gt;
        &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;glyphs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;layout&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;flatMap&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nv"&gt;$0&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;flatMap&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nv"&gt;$0&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;Double&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;glyphs&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;glyph&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;glyphs&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;enumerated&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;start&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;Double&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;count&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mf"&gt;0.7&lt;/span&gt;
            &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;amount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;max&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;progress&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;start&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mf"&gt;0.3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

            &lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="nv"&gt;copy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;
            &lt;span class="n"&gt;copy&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;opacity&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;amount&lt;/span&gt;
            &lt;span class="n"&gt;copy&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;translateBy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;x&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;y&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;copy&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;draw&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;glyph&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="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Animate &lt;code&gt;progress&lt;/code&gt; from 0 to 1 and you get this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F4d56hr68giz6huso3712.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F4d56hr68giz6huso3712.gif" alt="Example renderer gif" width="800" height="220"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 &lt;strong&gt;Tip:&lt;/strong&gt; Paul Hudson's &lt;a href="https://github.com/twostraws/Prismic" rel="noopener noreferrer"&gt;Prismic&lt;/a&gt; is a collection of ready-made renderers to play with. I'm starting there while exploring ways to bring some text renderers to my personal projects and also at work.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Building Beyond Mistakes (&lt;a href="https://github.com/FrankSolleveld" rel="noopener noreferrer"&gt;Frank Solleveld&lt;/a&gt;)
&lt;/h3&gt;

&lt;p&gt;My favourite talk on day two had no code in it. Frank wasn't even supposed to be doing a talk at the conference but as one of the other speakers fell ill, Frank was ready in the wings to give us his talk.&lt;/p&gt;

&lt;p&gt;This talk was different from the others. Frank talked about his start with iOS development, how he found the love for building things but as most of us did, he struggled when he had his first real taste of working in a company. I still remember myself the first time I worked on a real app as part of a company and how different that experience was compared to the apps I'd spent my own time building, so I could relate to this part of the talk.&lt;/p&gt;

&lt;p&gt;Frank took us on a journey, where he talked about his doubts and confidence knocks he had during the early start of his career but then how he managed to really excel and eventually find his way to where he is today. A few things from his talk that I'm taking with me:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Faknazl4631qeol59mfv9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Faknazl4631qeol59mfv9.png" alt="Franks tips" width="800" height="339"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;💬 People are just people, even conference speakers. Everyone is just part of the community.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This talk really resonated with me, and I think it did for everyone else too, as after speaking to other attendees it seemed to be everyone's favourite of the conference. I'm looking forward to seeing this one published online.&lt;/p&gt;




&lt;p&gt;Some other talks I really enjoyed...&lt;/p&gt;

&lt;h2&gt;
  
  
  🤖 Working with AI without losing the craft
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Bringing back the love of Swift (&lt;a href="https://www.avanderlee.com" rel="noopener noreferrer"&gt;Antoine van der Lee&lt;/a&gt;)
&lt;/h3&gt;

&lt;p&gt;Antoine opened the conference with this one. This talk hit the mark with everyone in the room, as I think we all ask ourselves quite often if the vast change to our careers due to AI has made us love the code we are writing less.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;💬 Are we losing our love of Swift as we write less of the code ourselves?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Antoine raised the concern that developers aren't really taking as many courses anymore. People are even reading fewer articles which doesn't bode well for me beginning to write more on this blog. He also went on to say that developers are exploring code less, but in reality we are shipping more than ever. &lt;/p&gt;

&lt;p&gt;I can only speak from my own experience but I feel that. I've always been a relatively high-output engineer and I'm a fan of having a few things on the go, but AI has made that a different ball game.&lt;/p&gt;

&lt;p&gt;The sheer amount of code output I see per week now with AI does mean that we aren't as close to the code we are writing and I know for myself, I'm reading less and exploring less online as a result. This talk made me reflect, and I think the outcome for me is that I want to ground myself more in the technology I'm using every day.&lt;/p&gt;

&lt;p&gt;Alongside these topics, Antoine shared some tips for working with AI, such as:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fcw6fo0xz51lwi17zo9lh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fcw6fo0xz51lwi17zo9lh.png" alt="Antoines tips" width="800" height="387"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;He also shared some handy tools:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://www.avanderlee.com/ai-development/agentic-ios-development-rocketsim-rockettrace/" rel="noopener noreferrer"&gt;RocketSim and RocketTrace&lt;/a&gt;, a CLI and agent skill for driving the simulator, plus Xcode Instruments for AI agents.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://sosumi.ai" rel="noopener noreferrer"&gt;sosumi.ai&lt;/a&gt;, Apple's docs (including the Human Interface Guidelines) in a form agents can read.&lt;/li&gt;
&lt;li&gt;His post on &lt;a href="https://www.avanderlee.com/ai-development/reduce-token-usage-claude-code-codex-cursor/" rel="noopener noreferrer"&gt;reducing token usage in Claude Code, Codex and Cursor&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Overall, I really enjoyed this one and I think we can all take something from it.&lt;/p&gt;

&lt;h3&gt;
  
  
  From Code to Outcomes (&lt;a href="https://www.linkedin.com/in/nmarcinska" rel="noopener noreferrer"&gt;Natalija Marcinska&lt;/a&gt;)
&lt;/h3&gt;

&lt;p&gt;Natalija (BBC Mobile) closed day one, and her talk felt like a nice follow-on from Antoine's, as it came at AI from the product side. Her point was that AI has made it easier than ever to build the wrong thing really quickly. You can build an amazing technical solution, but if your users don't actually need it then all of that time has been wasted.&lt;/p&gt;

&lt;p&gt;She talked about how engineers already make product decisions every day, so we should also be asking whether something should be built at all, and that discovery is part of engineering too. The line that stuck with me was this one:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;💬 The best code to delete is the code for a feature that would have wasted months.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;My takeaways from this one:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fzvcdaeg3jsp5vmvj2hjk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fzvcdaeg3jsp5vmvj2hjk.png" alt="Natalija tips" width="800" height="395"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  🗄️ You might not need a backend yet
&lt;/h2&gt;

&lt;h3&gt;
  
  
  CloudKit Public Database as a Backend (&lt;a href="https://www.danijelavrzan.com" rel="noopener noreferrer"&gt;Danijela Vrzan&lt;/a&gt;)
&lt;/h3&gt;

&lt;p&gt;Danijela opened day two, and her main advice was to avoid building a backend for as long as possible. So before reaching for one, ask yourself:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F63ns31tdelx17wa4i7nq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F63ns31tdelx17wa4i7nq.png" alt="CloudKit tips" width="800" height="311"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you do need shared data, the CloudKit Public Database might be the answer. It's managed by Apple, shared across all the users of your app and doesn't need an account system of your own. It's best for static-ish content though, and it isn't the place to store anything sensitive.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;⚠️ &lt;strong&gt;Tip:&lt;/strong&gt; Development and Production are separate environments in CloudKit. Don't forget to deploy your schema changes from Development to Production, and be aware that any records you upload to Development won't be carried across. If you've uploaded lots of data, you'll have to upload it all again.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This one got me thinking about my own app. Rather than baking configuration straight into the app, I could use the public database alongside the private one to store key content. Definitely one to explore.&lt;/p&gt;




&lt;h2&gt;
  
  
  📣 Building an audience
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Building an Audience for Your Apps (Joe Allen)
&lt;/h3&gt;

&lt;p&gt;Joe, who makes &lt;a href="https://teleprompterpro.com" rel="noopener noreferrer"&gt;Teleprompter Pro&lt;/a&gt;, closed out the conference. For years Joe slowly built up an email list from within his apps, so when he released something new, he let his audience know and got a huge influx of downloads. His point was that an audience is your unfair advantage:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;💬 Your competitors don't have &lt;em&gt;your&lt;/em&gt; audience.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The obvious worry is "I don't want to spam my users", and Joe's answer to that was... you could just not spam them. 😄 You do need to think about GDPR when you contact users though, and you shouldn't hold your content or features hostage just to get someone's email address.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 &lt;strong&gt;Tip:&lt;/strong&gt; Register the domains and addresses you send email from in your Apple Developer account (Certificates, Identifiers &amp;amp; Profiles, under Sign in with Apple for Email Communication). Users who Sign in with Apple may be using Private Relay, and without that setup your emails won't reach them.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I'd love to think more about how we do this at Depop. For my own apps, I'm keeping things private with no email list, so this blog is going to be my way of building an audience instead.&lt;/p&gt;




&lt;h2&gt;
  
  
  ⚡ The quickfire round
&lt;/h2&gt;

&lt;p&gt;There were plenty of other great talks too, so here's a quick look at the rest:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Unleash the power of Swift Charts&lt;/strong&gt; (Francesco Marini). This one was all about making your charts readable and accessible. Check your colour palette with &lt;a href="https://projects.susielu.com/viz-palette" rel="noopener noreferrer"&gt;Viz Palette&lt;/a&gt;, use a font you know is readable like &lt;a href="https://fonts.google.com/specimen/Lexend" rel="noopener noreferrer"&gt;Lexend&lt;/a&gt; or &lt;a href="https://opendyslexic.org" rel="noopener noreferrer"&gt;OpenDyslexic&lt;/a&gt;, format your legend and axes, and pick the right mark for the job (bar or line?). He also showed &lt;a href="https://developer.apple.com/documentation/tabulardata" rel="noopener noreferrer"&gt;TabularData&lt;/a&gt;, which is really handy for loading CSV and JSON into a &lt;code&gt;DataFrame&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CarPlay from Zero&lt;/strong&gt; (&lt;a href="https://eyadkelleh.com" rel="noopener noreferrer"&gt;Eyad Kelleh&lt;/a&gt; &amp;amp; &lt;a href="https://www.linkedin.com/in/maurice-pfurr" rel="noopener noreferrer"&gt;Maurice Pfurr&lt;/a&gt;). Eyad and Maurice built &lt;a href="https://www.chargeasmile.com" rel="noopener noreferrer"&gt;Charge a Smile&lt;/a&gt; to compare EV charging prices. CarPlay apps are built from Apple's templates rather than custom UI, and the entitlement you request decides which ones you get.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Vapor 5 is actually here&lt;/strong&gt; (&lt;a href="https://www.timc.dev" rel="noopener noreferrer"&gt;Tim Condon&lt;/a&gt;). Vapor 4 has been around since 2020 with over 300 releases, so this is a big one! Vapor 5 focuses on performance, structured concurrency throughout and macro-based routing. &lt;a href="https://blog.vapor.codes/posts/vapor-5-beta/" rel="noopener noreferrer"&gt;The beta is out now&lt;/a&gt; and I'm keen to give the macro-based routing a go.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Beyond Boilerplate: Production-Ready Swift Macros&lt;/strong&gt; (&lt;a href="https://kevinhomorales.com" rel="noopener noreferrer"&gt;Kevin Morales&lt;/a&gt;). Macros are great for stable, repeated patterns, but if the code changes often, or you'd only be saving a few lines, it's probably not worth it. I'm wondering whether there are some custom macros I could use for validation. &lt;a href="https://github.com/KevinhoMorales/BeyondBoilerplate-SwiftMacros" rel="noopener noreferrer"&gt;Sample code here&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Who Let the App Intents Out?&lt;/strong&gt; (&lt;a href="https://clairerimel.github.io" rel="noopener noreferrer"&gt;Claire Sivadier&lt;/a&gt;). App Intents let your app's actions run from Siri, Shortcuts and Apple Intelligence, and with the new Siri relying on them they're well worth a look. Claire's app &lt;a href="https://www.peticle.app" rel="noopener noreferrer"&gt;Peticle&lt;/a&gt; shows them off well.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Why Does Our Swift Code Work?&lt;/strong&gt; (&lt;a href="https://freddi.dev" rel="noopener noreferrer"&gt;Yuki Aki&lt;/a&gt;). I loved the analogy here: the compiler is the safe road and the runtime is the car driving along it. Yuki walked us through the pipeline from &lt;code&gt;.swift&lt;/code&gt; to AST, type-checked AST, raw SIL, canonical SIL, LLVM IR and finally a &lt;code&gt;.o&lt;/code&gt; file. It made me think more about how I structure my code, and how much the compiler has to work out in a single expression.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Getting physical: Using Swift for 3D printing&lt;/strong&gt; (&lt;a href="https://github.com/ebariaux" rel="noopener noreferrer"&gt;Eric Bariaux&lt;/a&gt;). With &lt;a href="https://github.com/tomasf/Cadova" rel="noopener noreferrer"&gt;Cadova&lt;/a&gt; you can design 3D-printable models in Swift, SwiftUI-style, and watch them update in real time in CadovaViewer, a bit like a SwiftUI preview. This one is purely for fun, but I'm definitely giving it a go.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Swift Meets Kotlin&lt;/strong&gt; (&lt;a href="https://github.com/sorunokoe" rel="noopener noreferrer"&gt;Yeskendir Salgara&lt;/a&gt;). Trackman shares its Domain and Data layers through Kotlin Multiplatform and keeps the UI and Presentation layers in native Swift, using &lt;a href="https://github.com/touchlab/SKIE" rel="noopener noreferrer"&gt;SKIE&lt;/a&gt; to make the bridge between them feel more like Swift. Even if you never use KMP, it's a good reminder that getting your layering right matters in any architecture.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🛠️ What I'm going to try
&lt;/h2&gt;

&lt;p&gt;So after two days of talks, here's what I'm taking away to try:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Playing around with &lt;code&gt;TextRenderer&lt;/code&gt; effects, starting with Prismic&lt;/li&gt;
&lt;li&gt;Adding App Intents for the main actions in my own app, and thinking about how I can future-proof it with all the Siri changes coming in&lt;/li&gt;
&lt;li&gt;Considering the CloudKit Public Database for storing information that all users can use&lt;/li&gt;
&lt;li&gt;Building an audience through this blog (no spam, I promise)&lt;/li&gt;
&lt;li&gt;The Vapor 5 beta, and maybe a 3D print designed in Swift&lt;/li&gt;
&lt;li&gt;And after Frank's talk, releasing something new in 2026&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A lot of these are going to end up in my side project, &lt;strong&gt;Second Skin&lt;/strong&gt;. It's an iOS app for keeping track of your tattoos: the pieces you have, the ideas you're collecting, the sessions you've booked and your aftercare routine. It's built in SwiftUI with no accounts and no servers, as everything syncs through your own iCloud, so Danijela's talk came at a pretty good time. It's still early days, but hopefully this is the something new that Frank's talk pushed me to release. I'll be writing more about building it here, so watch this space! 👀&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F18zekxytyc6ohgjmpu1z.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F18zekxytyc6ohgjmpu1z.jpg" alt="Swift Leeds farewell picture" width="800" height="1067"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Built by humans. A fitting way to close a conference where AI came up in so many of the talks.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Thanks to everyone who organised, spoke at and came along to SwiftLeeds this year, it was another great one. See you all at number seven! If you were there, I'd love to hear what your favourite talk was in the comments.&lt;/p&gt;

</description>
      <category>swift</category>
      <category>ios</category>
      <category>techtalks</category>
      <category>career</category>
    </item>
    <item>
      <title>Introduction to Swift! 🚀 (for complete beginners)</title>
      <dc:creator>Andy Lawler</dc:creator>
      <pubDate>Wed, 26 Feb 2020 15:53:30 +0000</pubDate>
      <link>https://dev.to/andylawler/introduction-to-swift-for-complete-beginners-c07</link>
      <guid>https://dev.to/andylawler/introduction-to-swift-for-complete-beginners-c07</guid>
      <description>&lt;h1&gt;So you want to get started with swift but don't know where to start? 🤔 &lt;/h1&gt;

&lt;p&gt;This will be the perfect introduction to Swift. Firstly, let's open up a playground so we have a space to practice writing our code. To do this, open Xcode and then click 'create new playground'. Just name your playground and you are off.&lt;/p&gt;

&lt;p&gt;The first thing you will spot is the line at the very top. UIKit is simply the framework which holds all of the components to build the apps you love. UIKit holds all the information on components such as buttons, labels, views and even controllers.&lt;/p&gt;

&lt;h2&gt; Let's get into the code! 🛠&lt;/h2&gt;

&lt;p&gt;Quickly before we start. I will not be covering printing out values. In Swift it's as easy as doing.&lt;/p&gt;

&lt;p&gt;One extra tip: You can use () in swift to add variables inside of speech marks.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight swift"&gt;&lt;code&gt;&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="nv"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Hello World!🚀"&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;// Hello World!🚀&lt;/span&gt;
&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="nv"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"This is the number &lt;/span&gt;&lt;span class="se"&gt;\(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="se"&gt;)&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;// This is the number 10&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt; Variables 🌦 &lt;/h3&gt;

&lt;p&gt;You might notice the var keyword instantly. Swift uses both variables and constants. Unlike languages like Java for example, swift can recognise types of variables so they do not always need to be pre-defined. You can instead use 'var' for variables that can change and 'let' for constants that will not change. Let's see an example of this!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight swift"&gt;&lt;code&gt;&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="nv"&gt;canChange&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;
&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;notChanging&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;
&lt;span class="c1"&gt;// we could now do &lt;/span&gt;
&lt;span class="n"&gt;canChange&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;
&lt;span class="c1"&gt;// this would change the variable. Whereas, if we did&lt;/span&gt;
&lt;span class="n"&gt;notChanging&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;
&lt;span class="c1"&gt;// we would get an error&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One thing to note, you can pre-define variables in Swift, if you want to do so, use this general syntax.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight swift"&gt;&lt;code&gt;&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="nv"&gt;a&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;Int&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;
&lt;span class="c1"&gt;// or&lt;/span&gt;
&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="nv"&gt;b&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Hello"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now that I've introduced variables the best way to go next is to talk about data types in Swift.&lt;/p&gt;

&lt;h3&gt; Data Types ✍️&lt;/h3&gt;

&lt;p&gt;Data types are always important in any programming language. With this blog, I'm assuming you have no prior programming knowledge so I will explain exactly what each type is with examples.&lt;/p&gt;

&lt;h4&gt; Integers &lt;/h4&gt;

&lt;p&gt;Integers in Swift are the exact same as integers in real life. If we want to store an integer we simply use the same process as specified above. We use either var or let and then assign an integer to that variable. Integers need to be wholes numbers. Luckily, if you need to represent as a decimal you could also use floats which we will cover later.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight swift"&gt;&lt;code&gt;&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;age&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;21&lt;/span&gt;
&lt;span class="c1"&gt;// assigning the integer 21 to the variable age&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Important note: If you would like to represent binary numbers, hex numbers or even octal numbers. You can do this! I will link to the Swift documentation which has more information on this. &lt;a href="https://docs.swift.org/swift-book/LanguageGuide/TheBasics.html" rel="noopener noreferrer"&gt;https://docs.swift.org/swift-book/LanguageGuide/TheBasics.html&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt; Strings &lt;/h4&gt;

&lt;p&gt;Strings are used to store words/character. In Swift we will use them to store text we can then use throughout our apps. Strings in swift are fairly simple. Remember, Swift can detect what data type a variable is so you do not need to define it if you don't want to.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight swift"&gt;&lt;code&gt;&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Andrew"&lt;/span&gt;
&lt;span class="c1"&gt;// my name is now Andrew&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt; Floats &lt;/h4&gt;

&lt;p&gt;Floating Point numbers are used when you want to store numbers that have decimal places. We use them to show off these numbers and they are often used for mathematics inside languages.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight swift"&gt;&lt;code&gt;&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;pi&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;3.14&lt;/span&gt;
&lt;span class="c1"&gt;// pi is now a float, not an integer&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt; Booleans &lt;/h4&gt;

&lt;p&gt;Booleans are used in Swift to store either True or False values. Booleans are useful when you want to check conditions. The main thing to remember with Booleans is that they are always either True or False, nothing else.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight swift"&gt;&lt;code&gt;&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;thisArticleIsAwesome&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
&lt;span class="c1"&gt;// as you can see this is now true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt; Optionals &lt;/h4&gt;

&lt;p&gt;Optionals are one of the key features of Swift which most people will not have seen before! An optional is when a value could or could not have a value. Optionals are really useful when defining variables that may be null. I won't go into any more detail than this. I'll show you what defining an optional will look like. With optionals, you have to define the type of the variable before hand.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight swift"&gt;&lt;code&gt;&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="nv"&gt;a&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;Int&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt;
&lt;span class="c1"&gt;// a is now an optional integer&lt;/span&gt;
&lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;
&lt;span class="c1"&gt;// a = Optional(5) &amp;lt;- this 5 needs to be unwrapped.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Just remember that if you define an optional and then assign a value to it, you will need to unwrap it. Let's see what unwrapping is!&lt;/p&gt;

&lt;h5&gt; Unwrapping Optionals &lt;/h5&gt;

&lt;p&gt;We have three different methods for unwrapping optionals that we could use. Force-Unwrapping, Optional-Chaining or Nil Coalescing. There are other ways of unwrapping but these are the main ones. Let's see what they are all about.&lt;/p&gt;

&lt;h6&gt; Force Unwrapping &lt;/h6&gt;

&lt;p&gt;Force unwrapping is when you append a ! onto the end of an optional to unwrap it to obtain its true value. The one thing to be aware of with force unwrapping is that it's very risky. It's only really a good idea to unwrap it using this method if you know the variable should have a value. If it doesn't and you force unwrap your program will crash. Let's look at an example!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight swift"&gt;&lt;code&gt;&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="nv"&gt;a&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="kt"&gt;Int&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt;
&lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;// prints Optional(10)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;// prints 10&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h6&gt; Optional Chaining &lt;/h6&gt;

&lt;p&gt;Optional chaining is using the ? operator to carry the optional value to retrieve some other value. This may not make complete sense so let's take a look at an example!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight swift"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="kt"&gt;Programmer&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="nv"&gt;favouriteWebsite&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;DevTo&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="kt"&gt;DevTo&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="nv"&gt;favouriteArticle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"this current article"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;Andy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;Programmer&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="kt"&gt;Andy&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;favouriteWebsite&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;DevTo&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;example&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;Andy&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;favouriteWebsite&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;favouriteArticle&lt;/span&gt; 
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;example&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;// prints this current article&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A few things to understand with this. We are chaining the optional of favouriteWebsite to then access the favourite Article. As you can see, we have assigned Andy.favouriteWebsite to DevTo. If you don't do this, the optional would still be nil, imagine the code without that line. Favourite website wouldn't be linked to anything at all. If you now look at the example line you can see us use the ?. This simply means we're chaining the optional. You can then see me use ! in the print statement to unwrap the optional. Even though favouriteArticle isn't an optional, as we've chained the value will be an optional.&lt;/p&gt;

&lt;h6&gt; Nil Coalescing &lt;/h6&gt;

&lt;p&gt;Nil Coalescing is using the double ?? operator to give a default value to a variable when you attempt to unwrap it. If the variable turns out to be nil, the default value specified is used instead. Let's look at an example!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight swift"&gt;&lt;code&gt;&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="nv"&gt;a&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="kt"&gt;Int&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt;
&lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="p"&gt;??&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;// prints 10 as a is not nil&lt;/span&gt;
&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="nv"&gt;b&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="kt"&gt;Int&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="p"&gt;??&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;// prints 6 as b is currently nil&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt; Collection Types 📦&lt;/h3&gt;

&lt;h4&gt; Arrays &lt;/h4&gt;

&lt;p&gt;Arrays are simply storage areas where you can store items/values to then use throughout your code. Arrays can be of many types and you can even create types to store in them. Let's take a look at an example.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight swift"&gt;&lt;code&gt;&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="nv"&gt;integerStorage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="kt"&gt;Int&lt;/span&gt;&lt;span class="p"&gt;]()&lt;/span&gt;
&lt;span class="n"&gt;integerStorage&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;integerStorage&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;// or&lt;/span&gt;

&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;integerStorage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="c1"&gt;// you could specify type 'var integerStorage: [Int]'&lt;/span&gt;

&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;chosenInt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;integerStorage&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note: Array values can be indexed as shown above, array indexes start at 0 and not 1. So your index values are always '0 .. count-1'.&lt;/p&gt;

&lt;h4&gt; Dictionaries &lt;/h4&gt;

&lt;p&gt;Dictionaries are used when you want a key:value pair. This means you can store one value that links to another value. Let's take a look!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight swift"&gt;&lt;code&gt;&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;ages&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="kt"&gt;Int&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"Andy"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;21&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Sophia"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;myAge&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ages&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"Andy"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;myAge&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;// prints out 21&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note: Values taken from dictionaries are always optional. You will need to unwrap them.&lt;/p&gt;

&lt;h4&gt; Sets &lt;/h4&gt;

&lt;p&gt;Sets are useful when dealing with types that you would like to query and or use mathematical set theory. Let's look at some basic examples and then look at the theory we could use.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight swift"&gt;&lt;code&gt;&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="nv"&gt;ourSet&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;Set&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;Int&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;ourSet&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;insert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Does our set contain 10? &lt;/span&gt;&lt;span class="se"&gt;\(&lt;/span&gt;&lt;span class="n"&gt;ourSet&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;contains&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="se"&gt;)&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;// prints does our set contain 10? true&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Set count: &lt;/span&gt;&lt;span class="se"&gt;\(&lt;/span&gt;&lt;span class="n"&gt;ourSet&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="se"&gt;)&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;// prints set count: 1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Examples of set theory: Union, Intersection, Subtracting.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Union allows you to join two sets together&lt;/li&gt;
&lt;li&gt;Intersection allows you to find common elements&lt;/li&gt;
&lt;li&gt;Subtraction allows you to subtract one set from another&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt; Tuples &lt;/h4&gt;

&lt;p&gt;Tuples are useful when you need to store values quickly but don't need something like an array or dictionary. As you can see, they look different to the other storage types but they are incredibly useful.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight swift"&gt;&lt;code&gt;&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;thisCourse&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Swift Tutorial"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;rating&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"This course is a &lt;/span&gt;&lt;span class="se"&gt;\(&lt;/span&gt;&lt;span class="n"&gt;thisCourse&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;type&lt;/span&gt;&lt;span class="se"&gt;)&lt;/span&gt;&lt;span class="s"&gt; and it has a rating of &lt;/span&gt;&lt;span class="se"&gt;\(&lt;/span&gt;&lt;span class="n"&gt;thisCourse&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rating&lt;/span&gt;&lt;span class="se"&gt;)&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;// This course is a Swift Tutorial and it has a rating of 10&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt; Operators ➕&lt;/h3&gt;

&lt;p&gt;Now that you know how to define and store your values, we should talk about what you can do with them!&lt;/p&gt;

&lt;h4&gt; Addition/Subtraction &lt;/h4&gt;

&lt;p&gt;I won't say much about addition and subtraction. In Swift it's fairly simple. Let's jump straight into the examples.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight swift"&gt;&lt;code&gt;&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;
&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;// prints 7&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;// prints 1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt; Multiplication/Division &lt;/h4&gt;

&lt;p&gt;Same as above. Multiplication and Division is fairly simply inside Swift. Let's look at the examples.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight swift"&gt;&lt;code&gt;&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;
&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 
&lt;span class="c1"&gt;// prints 10&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;// prints 2.5&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt; W?T:F (Ternary) &lt;/h4&gt;

&lt;p&gt;This operator get's the name W?T:F this stands for what, true, false. This is a good way to remember it! This operator is used when you want to check something and then apply different values for true or false. Let's take a look at an example!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight swift"&gt;&lt;code&gt;&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="nv"&gt;bool&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;example&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;bool&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="s"&gt;"True"&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"False"&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;example&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;// prints True&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt; Unary &lt;/h4&gt;

&lt;p&gt;The unary operator is simply used as a NOT operator. You use it show that you wan't the opposite of what it's used in conjunction with. Let's look at an example.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight swift"&gt;&lt;code&gt;&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="nv"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;// prints false&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt; Compound Assignment Operator &lt;/h4&gt;

&lt;p&gt;This is where swift is a tiny bit different to some other languages. In lot's of other programming languages there is a ++ or -- operator. This operator is used to add 1 or remove 1 from a variable. In swift this is not the case. Instead you must use += or -=. Let's look at some examples for this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight swift"&gt;&lt;code&gt;&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="nv"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;
&lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;// prints 20&lt;/span&gt;
&lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;-=&lt;/span&gt; &lt;span class="mi"&gt;11&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;// prints 9&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There are plenty of other operators in Swift but they are all similar to other programming languages. For the full list, check out the documentation below. &lt;a href="https://docs.swift.org/swift-book/LanguageGuide/BasicOperators.html" rel="noopener noreferrer"&gt;https://docs.swift.org/swift-book/LanguageGuide/BasicOperators.html&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt; Control Flow 🌊 &lt;/h3&gt;

&lt;p&gt;Control flow is something you will be using all the time when writing code in any language. It allows you to query, look through values and do so much more. Let's take a look at it in Swift.&lt;/p&gt;

&lt;h4&gt; For loop &lt;/h4&gt;

&lt;p&gt;For loops are used to loop through certain values. You can loop through arrays, dictionaries, sets or just through ranges. Let's take a look at some examples to see how they work!&lt;/p&gt;

&lt;p&gt;In our first example we loop through our names array using 'name' as the iterator. It could be called anything, it's doesn't have to be called names. We just call it names to the code itself is more readable. This loop will now go through each value in this loop and print them out.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight swift"&gt;&lt;code&gt;&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;names&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"Andy"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Brad"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"John"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;names&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="c1"&gt;// prints Andy Brad John&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this second example we are using ranges to print out numbers in a specified range. You can clearly see how the code below is printing from 0 to 4. This occurs because we use the 0..&amp;lt;5 operator. This simply says go from 0 to less than 5. You could change this to anything for example ... or ..&amp;gt; etc.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight swift"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;..&amp;lt;&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="c1"&gt;// prints 0 1 2 3 4&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt; While loop &lt;/h4&gt;

&lt;p&gt;While statements are loops that run based on a condition. For example, if you start a loop that says 'while a&amp;gt;5' the loop will keep running until a is &amp;lt;=5. These loops really useful. Let's look at how we could use them!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight swift"&gt;&lt;code&gt;&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="nv"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;
&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;-=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="c1"&gt;// prints 10 9 8 7 6&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Tip: You can use 'break' inside loops to stop them at any time. Let's look at an example.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight swift"&gt;&lt;code&gt;&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="nv"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;
&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
         &lt;span class="k"&gt;break&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="c1"&gt;// prints 10 and then breaks&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt; If statement &lt;/h4&gt;

&lt;p&gt;If statements are really important when it comes to checking conditions and making decisions. Let's take a look at some examples.&lt;/p&gt;

&lt;p&gt;Syntax: If, else if, else.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight swift"&gt;&lt;code&gt;&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="nv"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;
&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="nv"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Yes, a is 10"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"No, a is not 10"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"b is 3"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"b is 4"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"b is something else"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// prints Yes, a is 10 and b is something else&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you are interested in learning a more advanced version of control flow that acts like an if statement, take a look at this documentation to learn about guard statements. &lt;a href="https://docs.swift.org/swift-book/ReferenceManual/Statements.html" rel="noopener noreferrer"&gt;https://docs.swift.org/swift-book/ReferenceManual/Statements.html&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt; Switch statement &lt;/h4&gt;

&lt;p&gt;Switch statements are statements just like the others but they use control expressions and then cases. You can assign a default case and then cases for any possible value you want. This may not make complete sense so let's look at a basic example!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight swift"&gt;&lt;code&gt;&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="nv"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;
&lt;span class="k"&gt;switch&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Yes a is 10"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;default&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"No a is not 10"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="c1"&gt;// prints Yes a is 10&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The example above is a really simple example of Switch statements. You can also use enums for Switch statements and I haven't covered enums in this article. If you want to learn more, check it out here: &lt;a href="https://docs.swift.org/swift-book/LanguageGuide/ControlFlow.html" rel="noopener noreferrer"&gt;https://docs.swift.org/swift-book/LanguageGuide/ControlFlow.html&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt; Challenge Yourself! 🤓&lt;/h3&gt;

&lt;p&gt;I'll include some challenges here to see how much you have learned throughout. I'll post the code below the conclusion so you can check your work!&lt;/p&gt;

&lt;h5&gt; Task 1️⃣ &lt;/h5&gt;

&lt;p&gt;For this task, I would like to to write a simply program that can take an input of a shopping list and print out it's contents. The printed out list should look like this. Tip, use an array to manage the items.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight swift"&gt;&lt;code&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt; &lt;span class="kt"&gt;Apples&lt;/span&gt;
&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt; &lt;span class="kt"&gt;Pears&lt;/span&gt;
&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt; &lt;span class="kt"&gt;Lemons&lt;/span&gt;
&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt; &lt;span class="kt"&gt;Oranges&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;extension: Could you print how many items the user has overall?&lt;/p&gt;

&lt;h2&gt; Conclusion 🥳&lt;/h2&gt;

&lt;p&gt;I hope this was a good introduction to the language so you can now play around! If enough people are interested I'll make a video introducing Xcode and how to use it if you've never used it before. I hope everyone enjoyed this post!&lt;/p&gt;

&lt;h2&gt; Answers to the tasks 👨‍🏫 &lt;/h2&gt;

&lt;h3&gt; Task 1️⃣ &lt;/h3&gt;

&lt;p&gt;Just remember, the loop may print in a different order. This is perfectly fine!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight swift"&gt;&lt;code&gt;&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;shoppingList&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"Apples"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Pears"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Lemons"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Oranges"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="k"&gt;for&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 class="n"&gt;counter&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;shoppingList&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\(&lt;/span&gt;&lt;span class="n"&gt;counter&lt;/span&gt;&lt;span class="se"&gt;)&lt;/span&gt;&lt;span class="s"&gt;. &lt;/span&gt;&lt;span class="se"&gt;\(&lt;/span&gt;&lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="se"&gt;)&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// extension: print(shoppingList.count)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>ios</category>
      <category>swift</category>
    </item>
    <item>
      <title>Programmatic Constraints in Swift 📏</title>
      <dc:creator>Andy Lawler</dc:creator>
      <pubDate>Thu, 20 Feb 2020 22:48:12 +0000</pubDate>
      <link>https://dev.to/andylawler/programmatic-constraints-in-swift-kj</link>
      <guid>https://dev.to/andylawler/programmatic-constraints-in-swift-kj</guid>
      <description>&lt;p&gt;Have you always wanted to learn how to constrain your views and elements in Swift programatically and want to use no-libraries, well you are in the best place. This method of writing constraints is quite tedious in comparison to the likes of SnapKit but you will learn the fundamentals of constraints and then you can apply this knowledge to libraries like SnapKit in the future.&lt;/p&gt;

&lt;h2&gt; Let's get started 😀 &lt;/h2&gt;

&lt;p&gt;Firstly, we need to understand the key types of Anchors and what they all mean! Let's list the types out.&lt;/p&gt;

&lt;h4&gt; Types of Anchors ⚓️ &lt;/h4&gt;

&lt;p&gt;To constrain programmatically you must constrain to the pre-specified anchors that are provided for us to use. These are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Top (Anchor at the top of the view)&lt;/li&gt;
&lt;li&gt;Bottom (Anchor at the bottom of the view)&lt;/li&gt;
&lt;li&gt;Leading (Anchor at the left of the view)&lt;/li&gt;
&lt;li&gt;Trailing (Anchor at the right of the view)&lt;/li&gt;
&lt;li&gt;CenterX (Anchor on the centre of the X axis)&lt;/li&gt;
&lt;li&gt;CenterY (Anchor on the centre of the Y axis)&lt;/li&gt;
&lt;li&gt;Width (Anchor determining Width)&lt;/li&gt;
&lt;li&gt;Height (Anchor determining Height)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Remember: Usually you will need four constraints, never less. If you have more than four constraints you should see if you can improve the way you are constraining your elements.&lt;/p&gt;

&lt;p&gt;Now, let's look at the process of adding constraints and we can then explore examples of each type!&lt;/p&gt;

&lt;h4&gt; Process of adding constraints 👷🏼‍♂️&lt;/h4&gt;

&lt;p&gt;It's usually good practice to add your constraints directly under your view.addSubview(view) code. I usually have a process for adding constraints to elements. It looks a little bit like this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fjpho92s5gqbkt44td22r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fjpho92s5gqbkt44td22r.png" alt="Code for adding constraints" width="800" height="478"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You should always remember to make sure to add the new view as a subView of the main view and then make sure you change the bool as shown above. This bool allows us to write out our own custom programmatic constraints. A common mistake is to not make this false.&lt;/p&gt;

&lt;h4&gt; Examples of constraints using our Anchors &lt;/h4&gt;

&lt;p&gt;tip: Something I learned from Sean Allen is that you can define a padding type as a CGFloat and use this variable instead of manually inputting your constants. This allows you to change your UI from one position. Example below!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fztrztq0tsdj2gexlpegb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fztrztq0tsdj2gexlpegb.png" alt="Padding" width="700" height="446"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now we can delve into the examples. We will go through some examples and show different ways they could be implemented. Take into account there are many different types of constraints, eg: constants, multipliers. We are going to use constants, just take into account that where you see constant it could also be a multiplier if you needed it to.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fadxzqloxh1fcqwg9gtuu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fadxzqloxh1fcqwg9gtuu.png" alt="Constraint Types" width="797" height="149"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h5&gt; Top Anchor &lt;/h5&gt;

&lt;p&gt;This example below links the example view to the top of the main view with a distance of 40. this is a common way of setting up this type of constraint. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F3wljfei5t1r0vdzhobia.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F3wljfei5t1r0vdzhobia.png" alt="Top Anchor" width="798" height="248"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;tip: add safeAreaLayoutGuide in between view and topAnchor to pin to the safe area not the top of the view!&lt;/p&gt;

&lt;h5&gt; Bottom Anchor &lt;/h5&gt;

&lt;p&gt;This example below constrains the example view to the bottomAnchor with a distance of 10. Take into account that the number needs to be negative as we want the view to be away from the anchor not past it. This will make more sense when we do leading and trailing anchors.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fn8fqeyn6p6whxvn1cevw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fn8fqeyn6p6whxvn1cevw.png" alt="Bottom Anchor" width="800" height="253"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;tip: add safeAreaLayoutGuide in between view and bottomAnchor to pin to safe area once again.&lt;/p&gt;

&lt;h5&gt; Leading Anchor &lt;/h5&gt;

&lt;p&gt;The leading anchor is the anchor on the left hand side of the screen. The left hand side is the leading anchor as we imagine we are looking from left to right. With this knowledge we can verify that the trailing anchor is the anchor to the right. Leading anchor constants do not need to be negative as we want our view to be pinned to the right of the anchor.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fyssnj857jjjvhtzo7bxa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fyssnj857jjjvhtzo7bxa.png" alt="Leading Anchor" width="800" height="253"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h5&gt; Trailing Anchor &lt;/h5&gt;

&lt;p&gt;Key thing with trailing anchors is that the constant must be negative not positive as you are wanting your view to be x pixels behind the Anchor itself. The example below is the line we would add to make this possible. This examples shows us pinning a trailing anchor&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fhcryc042w9o4h4b95k66.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fhcryc042w9o4h4b95k66.png" alt="Trailing Anchor" width="800" height="253"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h5&gt; CenterX Anchor / CenterY Anchor &lt;/h5&gt;

&lt;p&gt;CenterX and CenterY Anchors are fairly self explanatory. We use them to center views when we need them to be fixed in an axis. These two anchors are useful for having an image in the exact center of the screen. I will show examples of pinning to the CenterX Anchor and also the CenterY Anchor but with a constant.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fcwfq349q6scjcpdszjak.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fcwfq349q6scjcpdszjak.png" alt="Center X Y Anchor" width="800" height="253"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h5&gt; Width Anchor / Height Anchor &lt;/h5&gt;

&lt;p&gt;Width and Height Anchors are quite self explanatory. These constraints allow you to add a width and height to your views. I will show you an example below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F95ef4o5gta59fd4kvuqq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F95ef4o5gta59fd4kvuqq.png" alt="Width Height Anchor" width="799" height="294"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt; Full Examples using what we have learned! ✍️ &lt;/h4&gt;

&lt;p&gt;Now let's put into practice what we've learned! I will include three full examples below showing valid constraints along with what they look like on the device!&lt;/p&gt;

&lt;h5&gt; Example 1 &lt;/h5&gt;

&lt;p&gt;This example shows how we can create a View and then pin the view to the edges of the phone. I've made the view red so you can see what's happening.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fu2f3uhhpmytdk2iarcy2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fu2f3uhhpmytdk2iarcy2.png" alt="Example 1 Code" width="799" height="536"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here you can see what's happening on the phone in red!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fu3pvfg8n26ak96c2wsrq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fu3pvfg8n26ak96c2wsrq.png" alt="Example 1 Phone" width="800" height="1731"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h5&gt; Example 2 &lt;/h5&gt;

&lt;p&gt;This example shows how we can pin a view to the centre of the phone and then add a width and height to it, you could use this for main screen logos! I used a variable for the box size so we can easily resize it if needed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F8mlpngslx950i9tqeom9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F8mlpngslx950i9tqeom9.png" alt="Example 2 Code" width="800" height="504"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here you can see what's happening on the phone in blue!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fz5sr5zyi7bh0hhqce9zb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fz5sr5zyi7bh0hhqce9zb.png" alt="Example 2 Phone" width="800" height="1731"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h5&gt; Example 3 &lt;/h5&gt;

&lt;p&gt;This example shows how we can create two views and stack them without using a stack view. This could be used to create some interesting designs! Look at the way I've pinned to the first views bottom anchor in the second views top anchor constraint.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fyr0p4hv8r6npjbuw25bg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fyr0p4hv8r6npjbuw25bg.png" alt="Example 3 Code" width="800" height="744"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here you can see what's happening on the phone in green and pink!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ffbroa4v4ywqylpsi53e1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ffbroa4v4ywqylpsi53e1.png" alt="Example 3 Phone" width="800" height="1731"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt; Review 🥳&lt;/h4&gt;

&lt;p&gt;Now you have seen examples of how to add constraints programmatically in Swift!&lt;/p&gt;

&lt;p&gt;If you have any additions for this post please do leave it in the comments, this is my first ever post so feedback would be appreciated! &lt;/p&gt;

</description>
      <category>swift</category>
      <category>appdevelopment</category>
      <category>ios</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
