Introduction to SwiftUI

⭐️ 👀 2023 WEB DEVELOPMENT BOOTCAMP starting in days! Join the waiting list to reserve your spot in my 10-weeks cohort course and learn the fundamentals, HTML, CSS, JS, Tailwind, React, Next.js and much much more! 👀 ⭐️

SwiftUI is the modern way to develop iOS, iPadOS, watchOS and macOS applications.

It is a paradigm shift from the “old” way, obsoleting many existing Apple frameworks: UIKit, AppKit and WatchKit.

Those frameworks have one thing in common: they are imperative.

You, the programmer, decide exactly how things should appear, pixel by pixel. You then respond to user events and manually update the data. On each change, you also decide how the UI should change.

SwiftUI is a total change because it’s reactive and the UI reflects the state of the data. No more “connecting things” like in UIKit.

And you write a lot less code. If you’ve ever written a iPhone app using UIKit before, you’ll think “that’s it?” all the time.

Speaking about code, with SwiftUI you just write code. No more StoryBoard or Interface Builder.

I find this perfect because I can store my code in Git and I can immediately see the changes made in time, over some XML gibberish.

Now, if you never worked with UIKit before, you’ll not understand what I mean. That’s good for you, don’t worry.

Since Apple was able to work on a clean slate with SwiftUI, we have so many advantages.

A first encounter with a SwiftUI app is fascinating.

This is the code of an Hello World app:

import SwiftUI

struct ContentView: View {
    var body: some View {
        Text("Hello World")
    }
}

You import the SwiftUI module, and you declare a struct that conforms to the View protocol.

This protocol requires that the struct has a computed property called body that returns some View.

And that’s what we do inside the struct.

The body computed property returns a single view of type Text, with the content Hello World in it.

Since you’ll see some View used all the time in SwiftUI, it’s a good time to explain why we use that and not just View.

This declaration forces body to always return a view of the same type, something that’s essential for how SwiftUI works.

One reason if performance. In order to be performant, SwiftUI needs to give some things for granted. One of those is that every struct returns the same kind of view, so it can easily check if it needs to be redrawn on screen, or not.

In this case we return a Text view, and this is what our struct will always return, regardless of its state.

One more thing! ⚠️ ✋

At the end of January I will organize the Web Development Bootcamp.

It's a 10-weeks long cohort online course where I will guide you to becoming a Web Developer.

It's not "just a course". It's a big event I organize once a year.

We'll start from zero, learn the fundamentals of Web Development, HTML CSS, JavaScript, Tailwind, Git, using the command line, VS Code, GitHub, Node.js, we'll then learn React, JSX, how to use PostgreSQL, Astro, Next.js, Prisma, deploying on Netlify/DigitalOcean/Fly/Vercel and much more! 

At the end of the first 10 weeks you'll know how to create web sites and web applications and I'll unlock you the 2nd phase of the Bootcamp: you will get access to a large number of projects exclusive to the Bootcamp graduates, so you can follow my instructions to build things like private areas with authentication, clones of popular sites like Twitter YouTube Reddit, create e-commerce sites, and much much more.

Because once you got the fundamentals, you only learn by working on real, exciting projects.

To find out more, visit bootcamp.dev