Check out a free preview of the full iOS App Development with Swift course:
The "Swift UI Overview" Lesson is part of the full, iOS App Development with Swift course featured in this preview video. Here's what you'd learn in this lesson:

Maximiliano discusses an overview of the multi-platform declarative UI framework Swift UI. Swift UI can use single or double-way data binding to re render dependencies.

Get Unlimited Access Now

Transcript from the "Swift UI Overview" Lesson

>> Now that we've seen something about Swift, let's talk a little bit about Swift UI, Swift UI first it uses the same icon with a different color than swift the language. Unfortunately, I'm not sure if it's the right name, right, I remember jQuery and jQuery Mobile that they were also having the same name.

[00:00:19] But they were completely different things, something similar happens here, Swift is a language, and Swift UI is a UI framework. Yeah, with Swift, but it's a UI framework, anyway, it's called Swift UI, and it's said declarative UI framework. So instead of using an XML or instead of creating a button like new button and setting the properties of the button.

[00:00:45] You're gonna use something, for now, let's say it's similar, but it's not similar, something similar to HTML, okay, or JSX in react, okay, like a template. It doesn't look like that, but it's the clarity, so the concepts are there, they're going to declarative create our user interface. It was launched a couple of years ago, it's still kind of new, we can say that it's a starting right now to feel like, okay, it's ready to create apps.

[00:01:15] I mean, the first year there were a lot of companies say, hey, I don't think it's ready, okay, bugs, some problems or limitations, but now it's start to feel that it's ready for primetime. It has a focus on modern UI patterns, such as having a single source of truth, so the data should live in one place and only one place, okay?

[00:01:42] Reusable views, we're not going to use a term component here, but every time we say views, it's like a component. In React, Angular or other frameworks, okay, a view it's something that we put on the screen, that can have properties, state, and we can reuse. Okay, that's the idea, it's multiplatform, so every view that you create, it's actually compatible with the watch, with the iPad, with the iPhone and with a Mac.

[00:02:13] And with the Apple TV, of course you have some specifics on the platform, but basics of two will work everywhere. And it has dependency rendering, which means similar to how react works or other declarative UI frameworks. We are going to define dependencies and every time one of those dependencies is changing, the view will re render.

[00:02:41] Okay, so it will automatically re render based on dependencies, so I don't need to rely on my own event binding, so it's not like on click, I'm going to change a view. Now unclick I'm going to change maybe the state, a dependency, a variable, and automatically the view knows, that, that dependency changes and it's going to re render the content.

[00:03:11] Okay, we're going to see this in action anyway, it uses data binding for that, so we connect the view with the data. And the view will automatically sync with the data every time the data changes and vice versa, we can have single way binding or double way binding, similar to Angular or other frameworks.

[00:03:35] And the UI is expressed in Swift structures, we don't use objects, we don't use classes, just structures and this is high performance. Because the structure is just data, and we can clone the data, we can create as much data if we want just memory. Really high performance memory, not objects with their own life cycles, no, no, just data, and then when that data is ready, the framework will render the abuse on the screen, okay?

[00:04:08] So we are going to be heavily based in structures, that's the only thing that we will create. Yeah, then we have the model and our business logic and maybe we can use classes on Opie there, but for swift UI, everything is a structure, okay? And we also have a visual editor in Xcode, that we will see later, so we can also see how my view looks like, while I'm bright in the code, okay, makes sense, do we have any question?

>> Seems the industry is going towards things like reactive programming, that's their answer or
>> Yeah, if you are a React developer, you will feel a lot of similarities, not in how it looks like because it's not JSX, but the ideas and how you think about your app.

[00:05:08] And how the app updates itself or how the components now as views here, how they are being re rendered, all the ideas are pretty similar. Okay, so with different syntax, but the idea, the patterns, the architecture patterns are the same/.