Understanding Swift Initializers

preview_player
Показать описание
As part of the Swift Deeper Understanding series I want to take a closer look at Initializers
We will take a look at what an initializer is for structs and classes and we will look at creating multiple initializers for a struct or class and find out what a Convenience initializer is.

We will finish the video by looking at how we can create a custom initializer for a SwiftUI HStack

If you want to support my work, you can buy me a coffee :)

Table of Contents:
0:00 Introduction
1:25 Introduction to Initializers
8:27 Multiple Initializers
14:35 Convenience Initializers
18:27 Custom HStack Initializer

Starter Project Files:
(If you are having problems downloading zip files, use Safari. Chrome restricts zip files by default)

Completed Project:

References mentioned in video:
Initializers Part 1

Initializers Part 2

Other References:
Stewart Lynch's YouTube Channel:
Stewart Lynch on Mastodon:
Stewart Lynch on Twitter:
Stewart Lynch on LinkedIn
Рекомендации по теме
Комментарии
Автор

I’m only through first 5 minutes and your explanation exploded the brick wall in front of me getting this! Your are truly the best instructor out there!

stephaniewagstaff
Автор

Great job again! I didn't expect to learn anything from this one, but I was wrong. Thanks

robertdavis
Автор

Great examples, especially the last example, changing the default implementation initializer. This helped me understand the SwiftUI documentation.

patgoo
Автор

Just a quick note that if you create an extension on a struct and add the other init() then you do not lose the member wise init

nigelgee
Автор

Special thanks for SwiftUI example ... 👏 if you can create video about how better understand documentation ... it´s will be amazing!

Mahadev-xu
Автор

Great content. The explanation of adding the init doc comment to make the quick help display the help text for API explanation should be required watching for API Producers!

DavidKoontz
Автор

It finally clicked with me. Thank you Stewart.

mhfs
Автор

In Xcode 14.3 I get a bunch of 'unknown context at $....' in the statement results frame for the let statements, which I don't see in your video. They appear to not have a bad effect.

dibjr