How to use inits and enums in SwiftUI | Bootcamp #13

  Переглядів 35,410

Swiftful Thinking

Swiftful Thinking

3 роки тому

In this video we will discuss the basics of inits and enums in SwiftUI views. Inits, formerly 'initializers', are functions that run when a view is created and are used to customize the view. We will first walk through the default inits that come standard in SwiftUI and then we will learn how to make our own custom init functions. After, we will briefly look at making custom enums (or enumerations) to make our Swift code organized and efficient.
We will cover:
(1) What is an init() in SwiftUI?
(2) How to customize init() in SwiftUI
(3) How to use enum in SwiftUI
Next video: • How to use ForEach loo...
Last video: • How to use Spacer in S...

КОМЕНТАРІ: 106
@markjensen5015
@markjensen5015 2 роки тому
I've looked at 3 books, and two paid courses, and Apple's own SwiftUI tutorial, and this is the best approach by FAR! Also, way better than anything I've seen on UKposts. Well done!
@SwiftfulThinking
@SwiftfulThinking 2 роки тому
Thanks Mark 😁 let me know if you have questions!
@natgenesis5038
@natgenesis5038 Рік тому
You deserve an Oscar I've been learning SwiftUI from you so far since the first step ..
@thyself125
@thyself125 2 роки тому
Holy shit dude! You are changing lives. You are demystifying this like crazy. I didn’t even know you could that in SwiftUI. I learned about swift basics but didn’t know the SwiftUI and swift structures were that same in the sense that they can have initializers. Gears are turning in my brain. Thank you!!!!! I can’t thank you enough.
@SwiftfulThinking
@SwiftfulThinking 2 роки тому
Hahaha if you thought this one was crazy just wait 😎
@muhammedturk_22
@muhammedturk_22 Рік тому
It is the best education set I have ever seen. Thank you...
@pitmanra
@pitmanra 3 роки тому
The init discussion at 11:00 is very helpful.
@taosade
@taosade Рік тому
I can't believe that's actually free! Thank you man! Your videos are BY FAR the best!
@ClintonSiegel
@ClintonSiegel Рік тому
Loved this tutorial! So clear and helpful.
@yourbestsail
@yourbestsail Рік тому
Just a stupid comment for precision's sake. The forward slash is this /, and the backslash is this \. Thank you for your excellent course.
@Lvoonok
@Lvoonok Рік тому
You are literally amazing, thank you for all your hard work and videos. I have learned more from your videos than reading documentations 🙏🙏🙏
@benceylan273
@benceylan273 2 роки тому
I understood init() for the first time :) Thanks mate!
@SwiftfulThinking
@SwiftfulThinking 2 роки тому
I could not be happier to hear that! It can definitely be confusing, but doesn't have to be :)
@yurialenccar
@yurialenccar Рік тому
Thanks for the explanation of init(). Totally helpful. You smashed it and has become easy for beginners.
@user-kr3dy2pn9h
@user-kr3dy2pn9h 4 місяці тому
I am so happy that I've found your channel. Thanks a lot Nick
@SwiftfulThinking
@SwiftfulThinking 4 місяці тому
Glad you enjoy it!
@DannyBoy443
@DannyBoy443 19 днів тому
I really liked this video. This was a high level but understandable yet useful high level code video.
@spradohak
@spradohak Рік тому
This video caused some light bulbs 💡 to go on in my head , as simple as it was but it really helped me to connect some dots. thank you so much for the quality content.
@user-fb6he4vb1u
@user-fb6he4vb1u Рік тому
THANK YOU SO MUCH NICK❤‍🔥❤‍🔥
@mehekpalrecha4262
@mehekpalrecha4262 Рік тому
I loved this video so much!
@user-dh6dw8gq1k
@user-dh6dw8gq1k 11 місяців тому
Eu sou br e acho q ngm vai ler isso, mas namoral que série perfeita, finalmente entendi para oque serve enums, nunca soube para o que era, valeu cara, tu tá me salvando muito.
@michelcusson2673
@michelcusson2673 2 роки тому
This is the best video I've seen on youTube.
@SwiftfulThinking
@SwiftfulThinking 2 роки тому
All of UKposts? 😂
@olepetersen4460
@olepetersen4460 2 роки тому
Very helpful! Thanks again.
@thematturlookingfor
@thematturlookingfor Рік тому
Dude this series is amazing. Im gunna make sure and give you a shout on some socials, these tutorials are just so ridiculously well done and should be top of the heap for people learning. Thanks for making them🤘🏻
@SwiftfulThinking
@SwiftfulThinking Рік тому
Haha thanks glad you’re liking them 🤙
@JPkatukenda
@JPkatukenda 2 роки тому
I am watching from the bottom. thank you for your effort
@comics-on
@comics-on 2 роки тому
Man, everything about this course is super helpful. However I'm glad to did a Swift programming course before this. I believe learning and mastering SwiftUI is already a daunting task without having to learn the language simultaneously.
@saeed_mxxx
@saeed_mxxx 2 місяці тому
thank you for sharing you knowledge 😘
@user-yd9xy3rb4x
@user-yd9xy3rb4x 2 роки тому
It is all related to Swift on to SwiftUI. Very basic level. Unluckily, I'd already known this stuff before watching, unluckily because the explanation is flawless even in X2.
@judej5150
@judej5150 Рік тому
watching your class from Korea. You're the best :) Thanks
@SwiftfulThinking
@SwiftfulThinking Рік тому
Hello Korea! 🤙
@yuchen3587
@yuchen3587 2 роки тому
The pace is not too fast nor slow. It is just perfect.
@SwiftfulThinking
@SwiftfulThinking 2 роки тому
Haha thanks Yuchen :)
@mkdevz3092
@mkdevz3092 Рік тому
Thank you! Clear and to the point 🫡
@rayhaanalykhan
@rayhaanalykhan 7 місяців тому
You know the funny part, this wouldn’t been a lot harder video, if I wasn’t already a UIKit developer who just came here to learn SwiftUI specifics in depth, so far the course is extremely well organised, especially for me because I like to do it slow but in depth.
@maheshkumarmudigonda6213
@maheshkumarmudigonda6213 5 місяців тому
Just Wow, Big Love you Bro ❣
@aniltodakar6449
@aniltodakar6449 3 місяці тому
Thanks for this video.
@Dragonboh1
@Dragonboh1 5 місяців тому
keep doing what you doing
@5thgenapps608
@5thgenapps608 2 роки тому
The ios courses I take on other places, nothing is as clear as your explanations. This is by far the best. Thank you for your effort.
@SwiftfulThinking
@SwiftfulThinking 2 роки тому
Thank you!!!
@simonwachtler2835
@simonwachtler2835 2 роки тому
Great Video! Thanks
@valerieokelly6224
@valerieokelly6224 Рік тому
Super clear 👍😎
@bbulliard
@bbulliard 2 роки тому
Wonderful video
@Nunny25
@Nunny25 2 роки тому
Very useful, thanks
@andrewmack4830
@andrewmack4830 Рік тому
great video. Thank you
@user-ev3dl9zt8s
@user-ev3dl9zt8s 3 роки тому
Thank you!!!
@pablo5433
@pablo5433 2 роки тому
My friend, I was about to give up SwiftUI and start studying Flutter😅, but thanks to your videos I have learned in a few days what I could not internalize in months. Thanks!!
@SwiftfulThinking
@SwiftfulThinking 2 роки тому
Hey Pablo! I'm glad you stayed with SwiftUI! I think it's a much smarter path to go down :)
@knowledgeispower4953
@knowledgeispower4953 3 місяці тому
good bro..😊
@ferusinfo
@ferusinfo 2 роки тому
As per discussion in 11:26, SwiftUI is not just "smart" - it works across Swift as a language: "Swift provides a default initializer for any structure or class that provides default values for all of its properties and doesn’t provide at least one initializer itself." This bootcamp is the greatest thing that exists for iOS developers - not only juniors, but seniors like me as well.
@shivammaheshwari8465
@shivammaheshwari8465 6 місяців тому
Yep, correct and also I believe since all views in SwiftUI are struct, and in Swift struct created automated designated initializers, that's why no need to write the init implementation so far
@mikem1451
@mikem1451 3 роки тому
Awesome video!!!
@SwiftfulThinking
@SwiftfulThinking 3 роки тому
Thanks!
@biffbiffson7350
@biffbiffson7350 2 місяці тому
Great examples eh. One always knows what's going on 🙂
@SwiftUA
@SwiftUA 2 роки тому
Thank you for the video
@SwiftfulThinking
@SwiftfulThinking 2 роки тому
Thank you Ярослав!
@Dorothyinstead
@Dorothyinstead 2 роки тому
To a lay person this subject appears quite daunting. However, as with all your previous videos Nick, your teaching style makes it much less overwhelming.
@SwiftfulThinking
@SwiftfulThinking 2 роки тому
I really appreciate these comments. Thanks for watching Rob! This is probably the hardest video in the series so far haha
@theflutterguy6301
@theflutterguy6301 7 днів тому
good video
@dr.craigcurphey4829
@dr.craigcurphey4829 3 роки тому
Once again I haft commend you on your approach. If you ever start some sort of support or consulting offer I would be very interested. Plus I believe by the end of this course I will be able to do my very unique app for which there is nothing else out there. Many thanks!
@SwiftfulThinking
@SwiftfulThinking 3 роки тому
Thanks Craig! I'm just glad someone's learning something. It makes making these videos all worth it!
@andrejkling3886
@andrejkling3886 3 роки тому
Thank you good tutorial...
@SwiftfulThinking
@SwiftfulThinking 3 роки тому
Haha thanks Andrej! You don't watch them in order do you 🧐 haha
@andrejkling3886
@andrejkling3886 2 роки тому
@@SwiftfulThinking Yes, I´ll start watching intermediate level, this level I just repeat again by jumping...-:)) but some point very useful and new for me... I like how you can observe from different corners... keep going Nick, I told you - you are smart...
@samarghourab5545
@samarghourab5545 2 роки тому
Hi there, thanks very much for these very helpful videos. I completely followed along the whole way through. I was just surprised we could change the view through the PreviewProvider (struct InitializerBootcamp_Previews) as opposed to only struct InitializerBootcamp: View. Is this a common practice or is it unlikely we would need to change the views in the PreviewProvider? I just imagine it getting complicated if the UI was complex and had a lot of components.
@rasheed1andrew
@rasheed1andrew 2 роки тому
I created an initializer that creates a row for a list. I created this same row before without the initializer but I think the code looks neat when its created as an initializer. this is where I find a problem,. on the last row I created, I was able to create an image that has an on tap gesture which updates the ui for the row. pretty much a subscription icon that changes color depending on what state the subscription is in. the function to update this ui is from a view model. do I add this function in the view where the instance was created and how? or do I add this function when I call the initializer in a different view within a list?
@andresraigoza2082
@andresraigoza2082 2 роки тому
Great content! Thanks. And maybe you would want to change the link of the next video, when I hit on that link, it takes me to this very same video.
@SwiftfulThinking
@SwiftfulThinking 2 роки тому
Thanks for letting me know 😅
@Devprogram
@Devprogram 2 місяці тому
cornerRadius will be deprecated, instead we will be possibly using clipShape rectangle
@user-np5vq9il1i
@user-np5vq9il1i 6 місяців тому
Hello thank you for lessons but i have some error (missing arguments for parameters 'backgroundColor', 'count', 'title' in call)
@jcclcreations7909
@jcclcreations7909 2 місяці тому
Was a Switch statement not used because this is a beginner course or is there another reason for it?
@user-gs9su3os9j
@user-gs9su3os9j 2 роки тому
Hi! Thanks for the video. Did everything as you said till 7:04, but after resume the system says: missing argument for parameter ‘backgroundColor’ in a call… what that might mean?
@aslanmmmdli1476
@aslanmmmdli1476 Рік тому
the same here. did u solve it?
@Jeff-zc6rr
@Jeff-zc6rr Рік тому
Why does it also require me to have an input parameter in the @main WindowGroup file and yours doesn't?
@gucp
@gucp Рік тому
Do I always have to use self.something when the conditional is within an innit? Is there another video explaining the use of self.?
@SwiftfulThinking
@SwiftfulThinking Рік тому
No you don’t need to use self. I was doing that to be clear in the tutorial that self. refers to the variable in the struct and not the variable passed into the struct (since they have the same name)
@gucp
@gucp Рік тому
@@SwiftfulThinking thanks! It makes sense now
@pitmanra
@pitmanra 3 роки тому
At 8:05, that's a backslash, not a forward slash. ; )
@SwiftfulThinking
@SwiftfulThinking 3 роки тому
lol oops -__-
@GabeColors
@GabeColors 2 роки тому
At 17:30 you say “when we type a period” how would I know that?
@SwiftfulThinking
@SwiftfulThinking 2 роки тому
Haha that's how enums work! We create an enum with a bunch of different options and then when we go to add one, Xcode automatically gives us the autocomplete with all of the options. I highly recommend using enums as much as possible!
@user-goldeneunga
@user-goldeneunga Рік тому
Can you please teach me what self. means?? I'm really confusing..
@SwiftfulThinking
@SwiftfulThinking Рік тому
self refers to the object that you’re in. So if your within a class and you call self, you’re referring to the parent class. I’ll try to do a video on this soon!
@user-goldeneunga
@user-goldeneunga Рік тому
@@SwiftfulThinking Thank you so much!! I'm learning swiftUI so well thanks to you!! You have so good pronuciation that me, Korea student can easily understand the video Thanks!
@SwiftfulThinking
@SwiftfulThinking Рік тому
@@user-goldeneunga Hello from across the world 👍
@belveloper
@belveloper 3 місяці тому
Self is the same as this in other languages Like dart java ...
@m__link6499
@m__link6499 3 роки тому
6’57 : why it doesn’t work for me when I fill the previews ?
@SwiftfulThinking
@SwiftfulThinking 3 роки тому
What error message are you getting?
@ubuandeyelbme
@ubuandeyelbme 2 місяці тому
\ = backslash I only bring it up cuz I was listening and typing and following along and I typed it wrong lol
@SwiftfulThinking
@SwiftfulThinking 2 місяці тому
💔😅
@SwiftfulThinking
@SwiftfulThinking 2 місяці тому
I’m learning too 😂
@ubuandeyelbme
@ubuandeyelbme 2 місяці тому
@@SwiftfulThinking hahaha! Stay reachable 😂
@m__link6499
@m__link6499 3 роки тому
What's wrong with this code please ? 🤔 struct ContentView: View { let name: String var body: some View { Text(name) .padding() } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView(name: "john") } }
@SwiftfulThinking
@SwiftfulThinking 3 роки тому
Hello! I copied and pasted the code and it works fine. I don't see any issue. Are you getting an error message?
@m__link6499
@m__link6499 3 роки тому
@@SwiftfulThinking Now suddenly I works...Very weird 🤔...thank you and keep going...Your videos are powerfull!!!
@user-yd9xy3rb4x
@user-yd9xy3rb4x 2 роки тому
It's not that hard if you know Swift language and switched from C#.
@user-ux9iq2hf5x
@user-ux9iq2hf5x Рік тому
Wrote exactly the same code as in the video, but an error occurs "missing arguments for parameters "backGroundColor", "count" , "title" in call. Help pls
@SwiftfulThinking
@SwiftfulThinking Рік тому
The source code is on my GitHub @SwiftfulThinking
@user-ux9iq2hf5x
@user-ux9iq2hf5x Рік тому
@@SwiftfulThinking you're the best, thanks
@douglasrutledge1325
@douglasrutledge1325 Рік тому
these two things I avoid: I guess it's time to learn...
@magedmohmed4403
@magedmohmed4403 Рік тому
Thanks Again , you are very helpful for us 🤎🤎
@UareAcreep
@UareAcreep 3 роки тому
Great video! Thanks
@SwiftfulThinking
@SwiftfulThinking 3 роки тому
Glad you liked it! Thanks for watching David.
@vortex5896
@vortex5896 3 роки тому
good video
@SwiftfulThinking
@SwiftfulThinking 3 роки тому
Thanks Vortex!
How to use ForEach loops in SwiftUI | Bootcamp #14
13:30
Swiftful Thinking
Переглядів 33 тис.
КТО СМОГ ПОБЕДИТЬ?😳
00:36
МЯТНАЯ ФАНТА
Переглядів 1 млн
Пескоструйный АППАРАТ! #shorts
01:00
Гараж 54
Переглядів 3,1 млн
How to use and ignore the Safe Area in SwiftUI | Bootcamp #17
17:24
Swiftful Thinking
Переглядів 24 тис.
How to use DragGesture to move, drag, swipe in SwiftUI | Continued Learning #4
30:42
VStack, HStack, and ZStack in SwiftUI | Bootcamp #10
21:37
Swiftful Thinking
Переглядів 35 тис.
What is Object Oriented Programming for Swift | Swift Basics #8
40:00
Swiftful Thinking
Переглядів 11 тис.
Understanding Swift Initializers
25:39
Stewart Lynch
Переглядів 4,5 тис.