How to use @Binding property wrapper in SwiftUI | Bootcamp #22

  Рет қаралды 34,408

Swiftful Thinking

Swiftful Thinking

3 жыл бұрын

The @Binding property wrapper helps us to connect a @State variable between the parent view and a child or secondary view. This is useful for any situation when we want to update a parent view from within the child view. In this video, you will understand the difference between the two property wrappers and when to implement each.
Next video: • How to use if-else and...
Last video: • How to Extract Subview...
🤙 WELCOME BACK 🤙
WEBSITE: www.swiftful-thinking.com
DISCORD: / discord
GITHUB: github.com/SwiftfulThinking/
SAY THANKS: www.buymeacoffee.com/nicksarno

Пікірлер: 80
@pitmanra
@pitmanra 3 жыл бұрын
Thanks for actually mapping out in the code how @State and @Binding work. No apologies needed. Some sites don't explain these things very well.
@dereklei1746
@dereklei1746 2 жыл бұрын
This bootcamp is so well structured that it serves well as a standalone course and a complimentary course and a reference handbook all at the same time. Thanks for such beautiful effort.
@SwiftfulThinking
@SwiftfulThinking 2 жыл бұрын
Thanks Derek! All of my playlists are structured like this 🚀🚀
@Filwoj00
@Filwoj00 3 жыл бұрын
This course is so damn good. Thank You!!!
@Seepho
@Seepho 2 жыл бұрын
Totally agree!
@leneil46
@leneil46 Жыл бұрын
Yes. He’s good!
@AllanZhang16
@AllanZhang16 8 ай бұрын
I watched many SwiftUI videos, and this is the best explanation of @Binding I have seen
@mihneagane9567
@mihneagane9567 Жыл бұрын
Thank you so much for this course! Wish Apple would be as passionate as you to make their tutorials this clear!
@vk1653
@vk1653 2 ай бұрын
Hey my dude don't apologizes cause you are really teaching this and honestly all this stuff the way you teach is actually sticking
@martinjonesdh
@martinjonesdh 2 жыл бұрын
Your explanations are fantastic. Such good content to allow people to learn. Thanks Martin
@CC-gh6xt
@CC-gh6xt 8 ай бұрын
Don't you ever be sorry Nick! This is great learning for noobs like me. You explain it so good Thank you!
@SokKanharith
@SokKanharith 2 жыл бұрын
I can't thank you enough for this series.
@muzammilali3222
@muzammilali3222 Жыл бұрын
Binding explained in a really good way. Thanks !
@thelambsauce2015
@thelambsauce2015 2 жыл бұрын
Very informative video, thank you so much for this!
@udonthavasoul
@udonthavasoul 2 жыл бұрын
You are the best. Thank you so much for doing this
@phillooby7241
@phillooby7241 Жыл бұрын
Thanks Nick. Great job explaining @Binding. I finally understand this
@gccount
@gccount 5 ай бұрын
The video explains so clear yet efficient. Apple should hire you as an engineer , to promote Swift and SwiftUI.
@JeckyKA
@JeckyKA 3 жыл бұрын
very very useful! thank you so much!
@abugslife2461
@abugslife2461 2 жыл бұрын
love it! thank you so much, very helpful!
@xinl370
@xinl370 11 ай бұрын
Super helpful videos! Really like the flow from video 19 to 22 (@State, extracting views, subviews, and then @Binding)
@user-fv3bb2bz5n
@user-fv3bb2bz5n Жыл бұрын
This playlist is really helpful. Thank you for making.🤗
@pearl4102
@pearl4102 2 жыл бұрын
You are Genius at teaching thank you so much
@huanzhouwang2871
@huanzhouwang2871 Жыл бұрын
super super clear!! I love it
@NTuneLabs
@NTuneLabs 2 жыл бұрын
Super Beginner? Yes, that's me... thank you for this series.
@oldschool84
@oldschool84 6 ай бұрын
Well explained! Thanks!
@jameskayten6563
@jameskayten6563 10 ай бұрын
I really liked this one!! Great job for clarity. And BTW - there's no need to apologize for the content being so beginner level - that's why we're here!
@sabyasachisahu6730
@sabyasachisahu6730 4 ай бұрын
Thank you so much man, for making this simple. I was stuck how to transfer text string between views. This really helped me understand teh concept.
@vignaanjunior382
@vignaanjunior382 6 ай бұрын
No need to apologize , even it's basic , it's important , Good Work !
@TheSociate
@TheSociate 2 жыл бұрын
I loved your bootcamp! if it didn't exist it would be harder to for me to get to know swiftui as an absolute beginner
@dugrut1325
@dugrut1325 2 жыл бұрын
you would be perfect for a traffic guard, my brain is starting to ooze ... Super Beginner is true, thus we watch [ aka: @State] these BootCamp videos.
@user-kn6fg4yv2w
@user-kn6fg4yv2w 11 ай бұрын
THANK U, you make difference
@yuchen3587
@yuchen3587 2 жыл бұрын
Crystal clear!
@Ankishkhatri
@Ankishkhatri 3 жыл бұрын
Super useful video. Thank you so much.
@SwiftfulThinking
@SwiftfulThinking 3 жыл бұрын
Thanks for watching Ankish!
@raymundoortiz7269
@raymundoortiz7269 2 жыл бұрын
Very good!!!!, leaving the variables with the same name is the correct way, but for this tutorial and to understand it correctly, I think it is better to change the names, greetings!
@emilymorrison6495
@emilymorrison6495 Жыл бұрын
Thank you!
@blytte
@blytte Жыл бұрын
Really, thank you very much!
@SwiftfulThinking
@SwiftfulThinking Жыл бұрын
Thanks Roberto! Welcome to the channel 🤙
@keshavkhaneja
@keshavkhaneja 2 жыл бұрын
thank you so so so much
@tomblah
@tomblah 2 ай бұрын
7:36 as I understand it, the $ sign gets the projectedValue of a property wrapper...for the @State property wrapper, the projectedValue is a @Binding property wrapper for the property
@kevniwoodside5015
@kevniwoodside5015 2 жыл бұрын
If I get a job, it'll solely be because of you. You are a GODSEND
@SwiftfulThinking
@SwiftfulThinking 2 жыл бұрын
It’s not an “if”, it’s a “when” 😉🤑
@kevniwoodside5015
@kevniwoodside5015 2 жыл бұрын
@@SwiftfulThinking You got that right!!! Im on my fourth round for a big job and suddenly they said there was "heavy" need for someone with SwiftUI skills so I lied and was like, "I've been making apps since I was a baby". Cut to me binging your stuff. Luckily it's a lot like other languages, but still, I'll buy you all the coffee you want if I get it cause of you!
@SwiftfulThinking
@SwiftfulThinking 2 жыл бұрын
@@kevniwoodside5015 Haha I hope you get it. Let me know!
@edhopkins6589
@edhopkins6589 Жыл бұрын
Outstanding video training for the beginner. I am on Bootcamp#22 ~enjoying it so much. I watch for a few minutes, then pause the video. I then type in the exact information into the XCODE editor. unpause, watch, pause, code, ... ~ until the end of the video. ^this method reinforces you practical teaching style. Thanks for such a great video series.
@SwiftfulThinking
@SwiftfulThinking Жыл бұрын
Thanks for the comment Ed!
@user-lj3cw2yq3f
@user-lj3cw2yq3f 10 ай бұрын
🔥🔥🔥
@leneil46
@leneil46 Жыл бұрын
🔥
@aleck30
@aleck30 8 ай бұрын
G.O.A.T.
@30guarino
@30guarino 3 жыл бұрын
Hey Nick..... Great videos! Just started with SwiftUI but still on UIKit. Going to go back to your Udemy course to actually start doing it after you're done with the Bootcamp. ......FYI ...organize the playlist #17 & #18 are out of order because of the updates you showed us......Thanks again
@SwiftfulThinking
@SwiftfulThinking 3 жыл бұрын
Haha thanks David! I just fixed the playlist... still getting the hang of KZfaq :)
@30guarino
@30guarino 3 жыл бұрын
@@SwiftfulThinking You're doing great!
@SurajKumar-uj4qt
@SurajKumar-uj4qt Жыл бұрын
great course i have repeated second time to improve my coding
@SwiftfulThinking
@SwiftfulThinking Жыл бұрын
Awesome. I’d imagine you’re getting pretty good then 🚀
@rangetwofan
@rangetwofan 3 жыл бұрын
Amazing Playlist and extreem learn full thank you soo much for this! I just starting to learn programming. Got one question i know it's not that much of a deal, but just wondering. here for example you crate a var backgroundColor: Color = Color.red while in a previous vid you did backgroundColor: Color = .red. Some story in the body under the button. do you have a reason why you sometimes skip Color? Or i'm seeing pink elephants and there is no reason behind it?
@arslanrasit
@arslanrasit 10 ай бұрын
Omg this state management is way simpler than Flutter
@toastrecon
@toastrecon Жыл бұрын
Interesting! Can you call functions within the parent from the child? Say you had wanted the button to call a function within the main view that added a random number to a variable? Or, if you were using MVVM, you'd need to call a method on the view model...
@Jump_Jay
@Jump_Jay 2 жыл бұрын
I'm still just a little hazy on using it. Do you have more examples of using it?
@Stevesvideoshelf
@Stevesvideoshelf 2 жыл бұрын
This is soo good! I feel like I'm learning a lot! I'm curious if in a later video you cover how to do this, but where the @State variables are @StateObject variables from @Published variables in a separate class? for instance: import SwiftUI class Data: ObservableObject { @Published var title = "Title" } struct ContentView: View { @StateObject var data = Data() var body: some View { VStack { Text(data.title) .padding() // I think I need to do something here? Or maybe I'm way off target. ButtonView(data: Binding) } } } struct ButtonView: View { @Binding var data: Data var body: some View { VStack { Button(action: { data.title = "Hello" }, label: { Text("Button") }) } } } // In any case Thanks again for all the effort you put into these!
@SwiftfulThinking
@SwiftfulThinking 2 жыл бұрын
Haha what you're describing is a ViewModel. In all of my intermediate/advanced videos, we use MVVM architecture... which is this!
@Stevesvideoshelf
@Stevesvideoshelf 2 жыл бұрын
@@SwiftfulThinking Awesome! I look forward to getting to those 😁. I may or may not have already created an account on stack overflow where I asked the question and got an answer that enabled me to separate out all the views in an app I'm building into separate files... But I definitely will be taking your MVVM courses!
@dugrut1325
@dugrut1325 2 жыл бұрын
@@SwiftfulThinking hold the horses, lets get through the BootCamp first!
@techandbeauty22
@techandbeauty22 2 жыл бұрын
if I make the button like you showed. I want the background color and the text to change at the same time. so if the background color changes to Red then I want the text to say Red. how would I do that?
@zawiyarkhan6470
@zawiyarkhan6470 8 ай бұрын
if i have 2 views on 2 seperate swiftUI files, can i use this binding and state wrappers to share data between the views?
@dugrut1325
@dugrut1325 2 жыл бұрын
ok, my fourth+ time around this video. Now I realize you keep these @State and @Bindings between struct and Views. It's the only way they work... What about if you have a deep function and you want a progress of it cogs churning out data, like an actual real data update. How does that work? I hope you have time to answer and link to a video I can watch. THANKS
@alexpascal5403
@alexpascal5403 Жыл бұрын
Nick. My sister will pull your Peter for free. Since you have great tutorials, she’ll drive from ct to the island.
@raimitis
@raimitis 2 жыл бұрын
How did you select all Button part at 4:55?
@user-yd9xy3rb4x
@user-yd9xy3rb4x 3 жыл бұрын
What to do with a subview when your subview is created as a separate file? Preview gives me a mistake because I must determine an argument as a Binding type to enable the canvas to display the view.
@user-yd9xy3rb4x
@user-yd9xy3rb4x 3 жыл бұрын
never mind. I remember how to deal with the issue. I gotta utilize .constant(value) on the separate previewer's parameter. I hope I didn't mix some terms up.
@quervy4097
@quervy4097 3 жыл бұрын
@@user-yd9xy3rb4x I have different files and it doesn't work, help would be much appreciated?
@rasheed1andrew
@rasheed1andrew 3 жыл бұрын
I'm having a problem with binding. I created a button in a swift ui file and I created in another swift ui file an image that is supposed to animate. this image is an extracted subview of the second view. the same image has been used in another subview. when I create the state variable in the subview (the image itself) and bind it in the button file, I get an error on the preview file and every other subview that contains the image. how do I fix this. I hope I've explained this right.
@SwiftfulThinking
@SwiftfulThinking 3 жыл бұрын
Hi Rasheed, it's hard to tell what the problem is. When you create a @Binding in another file, you are creating an initializer in that file that requires you to connect the @Binding every time you create the file. So all of the previews are looking for this now. An easy way to fix the error is to use .constant() and put your image inside the parenthesis.
@knowledgeispower4953
@knowledgeispower4953 6 ай бұрын
sup bro...😇
@pigang14
@pigang14 Жыл бұрын
Hi, Nick, how are you? I have a small question. You have typed in your video backgroundColor = Color.orange (3:46, line 20) I typed backgroundColor = .orange and it still works. Is it difference between this 2 statements? Thank you!
@SwiftfulThinking
@SwiftfulThinking Жыл бұрын
There is nothing technically different. Depending on the situation, sometimes the compiler doesn’t know what type something is, so Color.orange confirms that .orange is a Color. I’m mostly doing that here bc it’s a beginner tutorial and want to be explicit 😅
@Jump_Jay
@Jump_Jay 2 жыл бұрын
Is there a Discord or StackOverflow for these videos?
@SwiftfulThinking
@SwiftfulThinking 2 жыл бұрын
Check the “Community” tab of the channel. There should be a link to the Discord 🔥
@magedmohmed4403
@magedmohmed4403 Жыл бұрын
I Want to Thank you very much man , you very helpful for us 🤎🤎
@magedmohmed4403
@magedmohmed4403 Жыл бұрын
Really , thank you nick for your helpful explanation tutorial 🤎🤎
@thanghoangngoc2564
@thanghoangngoc2564 2 жыл бұрын
Thank you!
How to use if-else and conditional statements in SwiftUI | Bootcamp #23
18:13
How to use @ObservableObject and @StateObject in SwiftUI | Bootcamp #50
35:12
哈莉奎因以为小丑不爱她了#joker #cosplay #Harriet Quinn
00:22
佐助与鸣人
Рет қаралды 8 МЛН
WORLD'S SHORTEST WOMAN
00:58
Stokes Twins
Рет қаралды 128 МЛН
Идеально повторил? Хотите вторую часть?
00:13
⚡️КАН АНДРЕЙ⚡️
Рет қаралды 9 МЛН
Survive 100 Days In Nuclear Bunker, Win $500,000
32:21
MrBeast
Рет қаралды 107 МЛН
How to use Do, Try, Catch, and Throws in Swift | Swift Concurrency #1
26:34
SwiftUI - @Binding Property Wrapper Explained - Passing Data
6:22
How to use @ViewBuilder in SwiftUI | Advanced Learning #9
24:01
Swiftful Thinking
Рет қаралды 25 М.
SwiftUI - Understanding State
8:37
Martin Lasek
Рет қаралды 6 М.
哈莉奎因以为小丑不爱她了#joker #cosplay #Harriet Quinn
00:22
佐助与鸣人
Рет қаралды 8 МЛН