<?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>Basics on Mike Gopsill</title>
    <link>https://www.mikegopsill.com/tags/basics/</link>
    <description>Recent content in Basics on Mike Gopsill</description>
    <generator>Hugo -- 0.161.1</generator>
    <language>en</language>
    <lastBuildDate>Tue, 24 Jun 2025 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://www.mikegopsill.com/tags/basics/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Swift Classes &amp; Inheritance</title>
      <link>https://www.mikegopsill.com/posts/swift-classes-inheritance/</link>
      <pubDate>Tue, 24 Jun 2025 00:00:00 +0000</pubDate>
      <guid>https://www.mikegopsill.com/posts/swift-classes-inheritance/</guid>
      <description>&lt;p&gt;Classes are a fundamental concept in &lt;strong&gt;Object-Oriented Programming (OOP)&lt;/strong&gt; and a cornerstone of Swift. In OOP, we model complex systems by creating &amp;ldquo;objects&amp;rdquo;—self-contained units that bundle data (properties) and behavior (methods). A class is the blueprint for creating these objects.&lt;/p&gt;
&lt;p&gt;Unlike &lt;a href=&#34;https://www.mikegopsill.com/posts/swift-structures/&#34;&gt;structures&lt;/a&gt;, classes have two key characteristics:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Inheritance&lt;/strong&gt;: A class can inherit functionality from a parent class, allowing you to build hierarchies of related types.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Reference Semantics&lt;/strong&gt;: Classes are &lt;em&gt;reference types&lt;/em&gt;. When you pass a class instance around, you&amp;rsquo;re passing a reference to the &lt;em&gt;same&lt;/em&gt; underlying object in memory.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Let&amp;rsquo;s look at a basic class:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Swift Structures</title>
      <link>https://www.mikegopsill.com/posts/swift-structures/</link>
      <pubDate>Sun, 22 Jun 2025 00:00:00 +0000</pubDate>
      <guid>https://www.mikegopsill.com/posts/swift-structures/</guid>
      <description>&lt;p&gt;Let&amp;rsquo;s talk about &lt;em&gt;structures&lt;/em&gt;, or &lt;code&gt;struct&lt;/code&gt;s as they&amp;rsquo;re known in code. Structures are a fundamental building block in Swift. They are versatile and widely used, from simple &lt;a href=&#34;https://www.mikegopsill.com/posts/swift-basic-data-types/&#34;&gt;data&lt;/a&gt; containers to more complex types with their own behavior.&lt;/p&gt;
&lt;h2 id=&#34;what-are-structures&#34;&gt;What are Structures?&lt;/h2&gt;
&lt;p&gt;A structure is a way to group related values together into a named type. Think of it like a blueprint for creating structures that hold specific kinds of data. For example, you could define a &lt;code&gt;struct&lt;/code&gt; to represent a 2D point with &lt;code&gt;x&lt;/code&gt; and &lt;code&gt;y&lt;/code&gt; coordinates, or a &lt;code&gt;struct&lt;/code&gt; to hold information about a book, like its &lt;code&gt;title&lt;/code&gt;, &lt;code&gt;author&lt;/code&gt;, and &lt;code&gt;pageCount&lt;/code&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Swift Enumerations</title>
      <link>https://www.mikegopsill.com/posts/swift-enumerations/</link>
      <pubDate>Sat, 21 Jun 2025 00:00:00 +0000</pubDate>
      <guid>https://www.mikegopsill.com/posts/swift-enumerations/</guid>
      <description>&lt;p&gt;Enums provide a way to define a common type for a group of related values. Enums create distinct cases for these values. Then you can work with, switch over and iterate through these distinct cases, making your code much more clear.&lt;/p&gt;
&lt;h2 id=&#34;what-are-enumerations&#34;&gt;What are Enumerations?&lt;/h2&gt;
&lt;p&gt;Think of enums as a way to create your own custom set of options. For example, the days of the week, the suits in a deck of cards, or the different states an application can be in.&lt;/p&gt;</description>
    </item>
    <item>
      <title>SwiftUI Stacks (HStack, VStack, ZStack)</title>
      <link>https://www.mikegopsill.com/posts/swiftui-stacks-hstack-vstack/</link>
      <pubDate>Thu, 19 Jun 2025 00:00:00 +0000</pubDate>
      <guid>https://www.mikegopsill.com/posts/swiftui-stacks-hstack-vstack/</guid>
      <description>&lt;p&gt;SwiftUI provides three basic containers for arranging views: &lt;code&gt;HStack&lt;/code&gt;, &lt;code&gt;VStack&lt;/code&gt;, and &lt;code&gt;ZStack&lt;/code&gt;. These stacks are used for creating simple and complex user interfaces. Let&amp;rsquo;s see how they work.&lt;/p&gt;
&lt;h2 id=&#34;vstack-arranging-views-vertically&#34;&gt;VStack: Arranging Views Vertically&lt;/h2&gt;
&lt;p&gt;A &lt;code&gt;VStack&lt;/code&gt; (Vertical Stack) arranges its child views in a vertical line, one on top of the other.&lt;/p&gt;
&lt;h3 id=&#34;example&#34;&gt;Example:&lt;/h3&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-swift&#34; data-lang=&#34;swift&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;VStack&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;n&#34;&gt;Text&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;Top Item&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;n&#34;&gt;Text&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;Middle Item&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;n&#34;&gt;Text&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;Bottom Item&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This will display three text views stacked vertically.&lt;/p&gt;
&lt;p&gt;&lt;img alt=&#34;swiftui vstack&#34; loading=&#34;lazy&#34; src=&#34;https://www.mikegopsill.com/posts/swiftui-stacks-hstack-vstack/swiftui_vstack.png#center&#34;&gt;&lt;/p&gt;
&lt;p&gt;By default, views within a &lt;code&gt;VStack&lt;/code&gt; are centered horizontally. You can control the alignment using the &lt;code&gt;alignment&lt;/code&gt; parameter:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Swift Optionals</title>
      <link>https://www.mikegopsill.com/posts/swift-optionals/</link>
      <pubDate>Tue, 17 Jun 2025 00:00:00 +0000</pubDate>
      <guid>https://www.mikegopsill.com/posts/swift-optionals/</guid>
      <description>&lt;p&gt;When you start learning Swift, one of the concepts you&amp;rsquo;ll encounter early on is &lt;em&gt;optionals&lt;/em&gt;. Optionals are a powerful feature of Swift that help you write safer and more robust code by explicitly handling the possibility that a value might be missing. This post will explain what optionals are, why they are important, and how to work with them.&lt;/p&gt;
&lt;h2 id=&#34;what-is-an-optional&#34;&gt;What is an Optional?&lt;/h2&gt;
&lt;p&gt;In Swift, an optional is a type that can hold either a value or no value at all. When an optional doesn&amp;rsquo;t have a value, it&amp;rsquo;s said to be &lt;code&gt;nil&lt;/code&gt;. Think of it like a box: the box might contain an item, or it might be empty.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Swift Closures</title>
      <link>https://www.mikegopsill.com/posts/swift-basics-closures/</link>
      <pubDate>Mon, 16 Jun 2025 00:00:00 +0000</pubDate>
      <guid>https://www.mikegopsill.com/posts/swift-basics-closures/</guid>
      <description>&lt;p&gt;Closures are self-contained pieces of code that you can store and pass around your  codebase. Think of them as unnamed functions that can capture and store references to any &lt;a href=&#34;https://www.mikegopsill.com/posts/swift-variables-constants/&#34;&gt;constants and variables&lt;/a&gt; from the context in which they&amp;rsquo;re defined. If you&amp;rsquo;ve used &lt;a href=&#34;https://www.mikegopsill.com/posts/swift-basics-functions/&#34;&gt;functions&lt;/a&gt; in Swift, then you&amp;rsquo;ll soon grasp closures as they are actually a special case of closures.&lt;/p&gt;
&lt;p&gt;Closures are used very often in iOS development. You&amp;rsquo;ll see them in: completion handlers, animations, collection methods like &lt;code&gt;map&lt;/code&gt; and &lt;code&gt;filter&lt;/code&gt;, and SwiftUI view builders. Let&amp;rsquo;s look at them in more detail.&lt;/p&gt;</description>
    </item>
    <item>
      <title>SwiftUI Text View</title>
      <link>https://www.mikegopsill.com/posts/swiftui-basics-text-view/</link>
      <pubDate>Sun, 15 Jun 2025 00:00:00 +0000</pubDate>
      <guid>https://www.mikegopsill.com/posts/swiftui-basics-text-view/</guid>
      <description>&lt;p&gt;The role of &lt;code&gt;Text&lt;/code&gt; view in SwiftUI is to display text (funny that). It can support simple labels, rich content or dynamic text. It is the SwiftUI equivalent to &lt;code&gt;UILabel&lt;/code&gt;. Let&amp;rsquo;s get look at it in more detail.&lt;/p&gt;
&lt;h2 id=&#34;creating-basic-text&#34;&gt;Creating Basic Text&lt;/h2&gt;
&lt;p&gt;Simply pass a string to the &lt;code&gt;Text&lt;/code&gt; initialiser:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-swift&#34; data-lang=&#34;swift&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;Text&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;Hello, SwiftUI!&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;img alt=&#34;swiftui text view&#34; loading=&#34;lazy&#34; src=&#34;https://www.mikegopsill.com/posts/swiftui-basics-text-view/swiftui_text.png#center&#34;&gt;&lt;/p&gt;
&lt;p&gt;You can also use string interpolation to create dynamic text:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-swift&#34; data-lang=&#34;swift&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kd&#34;&gt;let&lt;/span&gt; &lt;span class=&#34;nv&#34;&gt;userName&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;s&#34;&gt;&amp;#34;Mike&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;Text&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;Welcome back, &lt;/span&gt;&lt;span class=&#34;si&#34;&gt;\(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;userName&lt;/span&gt;&lt;span class=&#34;si&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;!&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;img alt=&#34;swiftui text view username&#34; loading=&#34;lazy&#34; src=&#34;https://www.mikegopsill.com/posts/swiftui-basics-text-view/swiftui_text_username.png#center&#34;&gt;&lt;/p&gt;</description>
    </item>
    <item>
      <title>Swift Functions</title>
      <link>https://www.mikegopsill.com/posts/swift-basics-functions/</link>
      <pubDate>Fri, 13 Jun 2025 00:00:00 +0000</pubDate>
      <guid>https://www.mikegopsill.com/posts/swift-basics-functions/</guid>
      <description>&lt;p&gt;Functions are reusable blocks of code that perform specific tasks. They&amp;rsquo;re fundamental to organising your code, avoiding repetition, and making your programs easier to understand and maintain. Think of a function as a mini-program that takes some input, does something useful with it, and optionally gives you back a result.&lt;/p&gt;
&lt;p&gt;In Swift, functions are first-class citizens—you can pass them around, store them in variables, and use them just like any other &lt;a href=&#34;https://www.mikegopsill.com/posts/swift-basic-data-types/&#34;&gt;data type&lt;/a&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Swift Control Flow</title>
      <link>https://www.mikegopsill.com/posts/swift-basics-control-flow/</link>
      <pubDate>Thu, 12 Jun 2025 00:00:00 +0000</pubDate>
      <guid>https://www.mikegopsill.com/posts/swift-basics-control-flow/</guid>
      <description>&lt;p&gt;Today we&amp;rsquo;ll look at control flow statements like &lt;code&gt;if&lt;/code&gt;, &lt;code&gt;for&lt;/code&gt;, and &lt;code&gt;switch&lt;/code&gt;. These statements are the decision makers of Swift, allowing you to create dynamic software. Understanding control flow means you can write code that can branch, loop, and make decisions based on the data it encounters.&lt;/p&gt;
&lt;h2 id=&#34;what-is-control-flow&#34;&gt;What is Control Flow?&lt;/h2&gt;
&lt;p&gt;&lt;em&gt;Control flow&lt;/em&gt; determines the order in which your code executes. Instead of just running line by line from top to bottom, control flow lets you skip sections, repeat operations, or choose between different paths based on conditions. It&amp;rsquo;s what transforms a simple list of instructions into intelligent software.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Swift Operators</title>
      <link>https://www.mikegopsill.com/posts/swift-basics-operators/</link>
      <pubDate>Wed, 11 Jun 2025 00:00:00 +0000</pubDate>
      <guid>https://www.mikegopsill.com/posts/swift-basics-operators/</guid>
      <description>&lt;p&gt;If you&amp;rsquo;ve been working with Swift for a while, you&amp;rsquo;ve probably been using operators without giving them much thought. They&amp;rsquo;re the symbols that let you perform calculations, compare values, and combine logic. Some examples include &lt;code&gt;+&lt;/code&gt;, &lt;code&gt;-&lt;/code&gt;, &lt;code&gt;==&lt;/code&gt;, and &lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt;. Understanding operators properly will help you write cleaner, more expressive Swift code.&lt;/p&gt;
&lt;h2 id=&#34;what-are-operators&#34;&gt;What Are Operators?&lt;/h2&gt;
&lt;p&gt;An &lt;em&gt;operator&lt;/em&gt; is a symbol that tells Swift to perform a specific operation on one, two, or three values. They are like the verbs of programming, that perform action on &lt;a href=&#34;https://www.mikegopsill.com/posts/swift-basic-data-types/&#34;&gt;data types&lt;/a&gt;&lt;/p&gt;</description>
    </item>
    <item>
      <title>Swift Basic Data Types</title>
      <link>https://www.mikegopsill.com/posts/swift-basic-data-types/</link>
      <pubDate>Tue, 10 Jun 2025 00:00:00 +0000</pubDate>
      <guid>https://www.mikegopsill.com/posts/swift-basic-data-types/</guid>
      <description>&lt;p&gt;If you&amp;rsquo;re just getting started with Swift, you&amp;rsquo;ll quickly realise that everything revolves around data—numbers, text, true/false values, lists of things. Understanding Swift&amp;rsquo;s basic data types is like learning the alphabet before you write sentences. This post covers the essential building blocks you&amp;rsquo;ll use in every Swift project.&lt;/p&gt;
&lt;h2 id=&#34;what-are-data-types&#34;&gt;What are Data Types?&lt;/h2&gt;
&lt;p&gt;A &lt;em&gt;data type&lt;/em&gt; defines the kind of data you’re working with and what actions you can perform on it. Are you handling a number or a name? A true/false flag or a list of groceries? Swift is a &lt;em&gt;strongly typed&lt;/em&gt; language, which means you must be clear about what types you’re working with. Swifts compiler will catch errors early if you make mistakes.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Swift Variables &amp; Constants</title>
      <link>https://www.mikegopsill.com/posts/swift-variables-constants/</link>
      <pubDate>Mon, 09 Jun 2025 00:00:00 +0000</pubDate>
      <guid>https://www.mikegopsill.com/posts/swift-variables-constants/</guid>
      <description>&lt;p&gt;Understanding variables and constants is one of the first steps in learning Swift. These building blocks will enable you to store, update, and manage data in your programs. In this post, we’ll cover what variables and constants are, how to use them, and why you should prefer one over the other depending on your use-case.&lt;/p&gt;
&lt;h2 id=&#34;what-are-variables&#34;&gt;What Are Variables?&lt;/h2&gt;
&lt;p&gt;A &lt;em&gt;variable&lt;/em&gt; is a named space in memory where you can store information that might change over time.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
