Binding vs. Bindable in SwiftUI on iOS 17

  Переглядів 7,081

donny wals

donny wals

10 місяців тому

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.

КОМЕНТАРІ: 37
@maDM72
@maDM72 8 місяців тому
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 6 місяців тому
Concur on the BG music.. or at the least make it far quieter.
@hdsenevi
@hdsenevi 4 місяці тому
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 3 місяці тому
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 Місяць тому
agreed. The background music is just obnoxious. Without it the video would be 10x better
@timnewton4339
@timnewton4339 6 місяців тому
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 3 місяці тому
Thanks!
@jcteo1
@jcteo1 7 місяців тому
That really cleared things up for me. Thanks!
@Noem0
@Noem0 10 місяців тому
Really good video. Good explanation and on point for the new Observable Features from iOS 17. Thanks
@RobertHolzapfel
@RobertHolzapfel 2 місяці тому
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 2 місяці тому
Thanks, finally understand the bindable
@iosmayank
@iosmayank 10 місяців тому
Welcome to UKposts Creator life, Donny🎉 Nice video.
@qkrotor
@qkrotor 2 місяці тому
Nicely explained. I would say the music is a little distracting and doesn't add anything IMO.
@DonnyWalsdev
@DonnyWalsdev 2 місяці тому
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
@cub711
@cub711 8 місяців тому
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 3 місяці тому
Unfortunately you can't
@yourbestsail
@yourbestsail 9 місяців тому
All fine. You should just improve audio and microphone. Sound is everything, especially in this kind of videos.
@DonnyWalsdev
@DonnyWalsdev 9 місяців тому
Thanks! I'll definitely try and improve that for the next one(s)
@NouvelEmpire
@NouvelEmpire 2 місяці тому
ultra interesting
@DonnyWalsdev
@DonnyWalsdev 2 місяці тому
Thanks!
@obelix8477
@obelix8477 7 місяців тому
Yes, please. Do not add background music.
@victorriurean
@victorriurean 6 місяців тому
@user-jz8op2dc4e
@user-jz8op2dc4e Місяць тому
Why can you input content in the canvas preview? How do I set it up?
@DonnyWalsdev
@DonnyWalsdev 19 днів тому
You can start "playing" the canvas from the previews UI and that should make it interactive
@angrypi
@angrypi 9 місяців тому
why does @bindable only work for `class` type?
@DonnyWalsdev
@DonnyWalsdev 9 місяців тому
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.
@dre5671
@dre5671 8 місяців тому
@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 8 місяців тому
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
@roym27
@roym27 16 днів тому
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 15 днів тому
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
@lapusan2008
@lapusan2008 6 місяців тому
Thank you! I was looking for a solution to the exact same problem you have addressed. Environment -> @Bindable
@danstoian7721
@danstoian7721 6 місяців тому
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 6 місяців тому
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 3 місяці тому
@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)
@khaledsh8506
@khaledsh8506 4 місяці тому
So basically, replace @EnvironmentObject with @Bindable
@DonnyWalsdev
@DonnyWalsdev 3 місяці тому
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
What's New in SwiftUI State Management
29:48
azamsharp
Переглядів 6 тис.
Мама и дневник Зомби (часть 1)🧟 #shorts
00:47
Bro smelt it & passed out 😂 #comedy
00:10
MrTalalaa
Переглядів 7 млн
Помилка,  яку зробило військове керівництво 🙄
01:00
Радіо Байрактар
Переглядів 371 тис.
I PUT MY ARMOR ON (Creeper) (PG Version)
00:19
Sam Green
Переглядів 6 млн
Why I don't do MVVM anymore
10:56
Flo writes Code
Переглядів 6 тис.
How to determine where code runs in Swift Concurrency
12:42
donny wals
Переглядів 1,6 тис.
New SwiftUI Data Flow with Observation - iOS 17
8:30
iOS Academy
Переглядів 6 тис.
@Observable @Bindable: MVVM in iOS 17
4:14
Flo writes Code
Переглядів 5 тис.
Comparing @Observable to ObservableObjects in SwiftUI
12:57
SwiftData with MVVM | Does it make sense?
7:28
Flo writes Code
Переглядів 7 тис.
8 Common SwiftUI Mistakes - and how to fix them!
28:05
Paul Hudson
Переглядів 49 тис.
@Observable @Bindable in iOS17 - SwiftUI Data Flow
12:22
Rebeloper - Rebel Developer
Переглядів 2,1 тис.
【獨生子的日常】让小奶猫也体验一把鬼打墙#小奶喵 #铲屎官的乐趣
0:12
“獨生子的日常”YouTube官方頻道
Переглядів 64 млн
Эта Девушка Королева Тортов 😁
0:39
MrGolub
Переглядів 2,2 млн
Плохая прическа😮 (TT oconnells)
0:19
Pieyon
Переглядів 12 млн
Фанаты захейтили девушку😭
0:35
Astronaut-Stories
Переглядів 11 млн
когда одна дома // EVA mash
0:51
EVA mash
Переглядів 7 млн