Binding vs. Bindable in SwiftUI on iOS 17

  Рет қаралды 9,595

donny wals

donny wals

Жыл бұрын

Learn everything you need to know about SwiftUI's new Bindable property wrapper. I will show you the problem that it solves, and why it doesn't replace @Binding by any means.

Пікірлер: 43
@maDM72
@maDM72 11 ай бұрын
Great content, keep going! The only thing - PLEASE remove the background music. That extra noise really makes it hard to listen to you, especially annoying if you watch at 1.5-2x speed (which I often do). Check how the Fireship channel does the narration without almost anything but his voice, and that's great. Thanks and good luck!
@tattooedpierre
@tattooedpierre 9 ай бұрын
Concur on the BG music.. or at the least make it far quieter.
@hdsenevi
@hdsenevi 7 ай бұрын
I second this comment as well. BG music is super distracting. That said, awesome video and keep them coming. Thanks for doing this. Please lower or remove background music on future videos
@DonnyWalsdev
@DonnyWalsdev 6 ай бұрын
Thanks! I've uploaded a new video with the bg music far lower, it's the most recent one on the channel so feel free to take a look. The reason I've included it is because to me narration with complete silence is rather boring and lots of channels I watch do have very mild music playing in the background. I might end up removing it in future videos but I want to give it a few tries to see if there's a sweet spot.
@mario_luis_dev
@mario_luis_dev 3 ай бұрын
agreed. The background music is just obnoxious. Without it the video would be 10x better
@timnewton4339
@timnewton4339 9 ай бұрын
Thank you very much. I've watched a number of videos introducing @Bindable, but none have been so clear to explain its purpose (with such a simple example) as yours.
@DonnyWalsdev
@DonnyWalsdev 6 ай бұрын
Thanks!
@jcteo1
@jcteo1 10 ай бұрын
That really cleared things up for me. Thanks!
@Noem0
@Noem0 Жыл бұрын
Really good video. Good explanation and on point for the new Observable Features from iOS 17. Thanks
@RobertHolzapfel
@RobertHolzapfel 5 ай бұрын
When I just thought that video could not be any better, you brought the issue with @Environment after 11 minutes on the table: AWESOME! Thank you so much for this video. I spent a whole day and night with that nightmare error message "can't find controller in the scope", which was exactly the situation that you describe here (in my case 'controller' is kind of a viewmodel). So, this video came to rescue me, although I found it very late. Thanks again !!! 🤩
@shuodeng3831
@shuodeng3831 5 ай бұрын
Thanks, finally understand the bindable
@iosmayank
@iosmayank Жыл бұрын
Welcome to KZfaq Creator life, Donny🎉 Nice video.
@ivanmatkovic
@ivanmatkovic 26 күн бұрын
When viewModel is @Observable, you dont need @State in the View. Great video btw
@DonnyWalsdev
@DonnyWalsdev 23 күн бұрын
You do if that view creates/owns the state. Otherwise every time a new struct instance is made a new instance of the Observable is made.
@cub711
@cub711 11 ай бұрын
Nice video, that I will come back to every time I mess up this. How can you use this without importing Observation? (Or SwiftData which also includes observation)
@DonnyWalsdev
@DonnyWalsdev 6 ай бұрын
Unfortunately you can't
@yourbestsail
@yourbestsail Жыл бұрын
All fine. You should just improve audio and microphone. Sound is everything, especially in this kind of videos.
@DonnyWalsdev
@DonnyWalsdev Жыл бұрын
Thanks! I'll definitely try and improve that for the next one(s)
@priyanka7782
@priyanka7782 2 ай бұрын
@@DonnyWalsdev and if possible, move mic away from keyboard too. Bit difficult to focus on what's being said.
@user-jz8op2dc4e
@user-jz8op2dc4e 4 ай бұрын
Why can you input content in the canvas preview? How do I set it up?
@DonnyWalsdev
@DonnyWalsdev 3 ай бұрын
You can start "playing" the canvas from the previews UI and that should make it interactive
@NouvelEmpire
@NouvelEmpire 5 ай бұрын
ultra interesting
@DonnyWalsdev
@DonnyWalsdev 5 ай бұрын
Thanks!
@qkrotor
@qkrotor 5 ай бұрын
Nicely explained. I would say the music is a little distracting and doesn't add anything IMO.
@DonnyWalsdev
@DonnyWalsdev 5 ай бұрын
Thanks! i do like to have some sound in the background instead of pure silence so in my latest video I brought the volume down by a lot. It's an ongoing experiment for the moment
@angrypi
@angrypi Жыл бұрын
why does @bindable only work for `class` type?
@DonnyWalsdev
@DonnyWalsdev Жыл бұрын
Probably because reference semantics are needed to ensure that you can actually observe a specific instance instead of having multiple separate copies that would get out of sync.
@obelix8477
@obelix8477 10 ай бұрын
Yes, please. Do not add background music.
@benceylan273
@benceylan273 Ай бұрын
Background music was distracting sorry.
@dre5671
@dre5671 11 ай бұрын
@State is no longer required with @Observable macro on your model/view model 🎉. Since the model is now observed, watching for changes, it will efficiently update the views the are using any property outputting change
@DonnyWalsdev
@DonnyWalsdev 11 ай бұрын
That's true for the observation part. But if you want the observable model's state to correctly be persisted you need @State to prevent SwiftUI from making a new instance every time your view struct is initialized. Note that this is only the case if you _own_ the observable in the view. Views that receive the instance in their init can indeed use a plain let/var
@wjcnwjcn
@wjcnwjcn 2 ай бұрын
What about this? kzfaq.info/get/bejne/lb6Ke92dmLiVdqM.html
@DonnyWalsdev
@DonnyWalsdev 2 ай бұрын
What about it? Is there something specific from that video you think I should look at?
@lapusan2008
@lapusan2008 9 ай бұрын
Thank you! I was looking for a solution to the exact same problem you have addressed. Environment -> @Bindable
@roym27
@roym27 3 ай бұрын
I had to stop watching because of the background music - it’s not great when you’re narrating as I was unable to focus on what you were saying.
@DonnyWalsdev
@DonnyWalsdev 3 ай бұрын
I'll probably do a re-record of this video at some point without the bg music. It's a shame that it's not possible to "update" a video without a full reupload
@danstoian7721
@danstoian7721 9 ай бұрын
10:33 One question, at line 11, you have @State on a class, should that not be @StateObject instead? And if not, if that's all done. Is there any longer a need for @StateObject?
@helgessons
@helgessons 9 ай бұрын
If I understood it correctly from another source, it seems like before there was a memory leak with using @state with a class but now with iOS 17 that has been fixed and it's now recommended to use @state instead. However I'm not 100% sure so please double check yourself as well :)
@DonnyWalsdev
@DonnyWalsdev 6 ай бұрын
@StateObject should be used for instances of ObservableObjects that you create in the view. So if a view creates an ObservableObject instance that you want to observe, you use @StateObject. When you're using the new @Observable macro, the SwiftUI view will observe your object no matter what. You use @State in order to make sure that the Observable instance you create persists when SwiftUI makes new instances of your view in response to model changes. Without @State you'd end up with fresh instances of your Observable every time a new view struct instance is created (which can be quite often)
@victorriurean
@victorriurean 9 ай бұрын
@khaledsh8506
@khaledsh8506 7 ай бұрын
So basically, replace @EnvironmentObject with @Bindable
@DonnyWalsdev
@DonnyWalsdev 6 ай бұрын
No, an environment object is an object that conforms to ObservableObject and lives in the environment. An @Bindable property allows you to bind to properties of an Observable instance because without it yu can't bind at all. The environment and @Bindable both solve very different problems so you can't replace one with the other
iOS 17 Data Flow with Observation Framework
28:41
Stewart Lynch
Рет қаралды 8 М.
MISS CIRCLE STUDENTS BULLY ME!
00:12
Andreas Eskander
Рет қаралды 18 МЛН
Получилось у Миланы?😂
00:13
ХАБИБ
Рет қаралды 3,3 МЛН
Inside Out 2: Who is the strongest? Joy vs Envy vs Anger #shorts #animation
00:22
Actor Reentrancy in Swift explained
20:18
donny wals
Рет қаралды 1,4 М.
SwiftData Basics in 15 minutes
15:18
CodeWithChris
Рет қаралды 41 М.
SwiftUI Alerts - Buttons, TextFields, & Passing Errors
13:18
Sean Allen
Рет қаралды 4,8 М.
What's New in SwiftUI State Management
29:48
azamsharp
Рет қаралды 6 М.
Comparing @Observable to ObservableObjects in SwiftUI
12:57
donny wals
Рет қаралды 1,2 М.
State & Binding | SwiftUI in 5 minutes | 2020
4:44
Krass Iankov
Рет қаралды 15 М.
How to drink orange juice legally @kahoko6607
0:29
OHIOBOSS SATOYU
Рет қаралды 22 МЛН
Bro didn’t make it 😬😟💀 (FAKE NOT REAL) #shorts
0:19
Nate Nahhh
Рет қаралды 9 МЛН
How to drink orange juice legally @kahoko6607
0:29
OHIOBOSS SATOYU
Рет қаралды 22 МЛН
ГОНКИ НА САМОКАТАХ #олегкинли
0:19
ОЛЕГ КИНЛИ
Рет қаралды 2,5 МЛН
3Funny Kids‼️ with Higher and Beautiful LEGO😂| JJaiPan #Shorts
1:00
เจไจ๋แปน J Jai Pan
Рет қаралды 8 МЛН