No video

Use PreferenceKey to extract values from child views in SwiftUI | Advanced Learning #10

  Рет қаралды 18,111

Swiftful Thinking

Swiftful Thinking

2 жыл бұрын

In this video we will learn the basics of how to use Preference Keys and then jump into some realistic examples of when this would come in handy in a real-world iOS application. In order to get the most out of this video, it is recommended to have watched the previous videos in this series on Generics and ViewBuilder.
Generics: • How to use Generics in...
ViewBuilder: • How to use @ViewBuilde...
🤙 WELCOME BACK 🤙
WEBSITE: www.swiftful-thinking.com
DISCORD: / discord
GITHUB: github.com/SwiftfulThinking/
SAY THANKS: www.buymeacoffee.com/nicksarno

Пікірлер: 64
@monstrositylabs
@monstrositylabs Жыл бұрын
You are the only iOS dev I can handle listening to. Everyone else waffles on and sends me to sleep.
@SwiftfulThinking
@SwiftfulThinking Жыл бұрын
😂😴
@cinquain0
@cinquain0 2 жыл бұрын
This is probably the most confusing lesson I’ve seen so far from Nick. I’ll definitely need to rewatch
@SwiftfulThinking
@SwiftfulThinking 2 жыл бұрын
We’re going to use these in the next 2 videos so you’ll get some practice 🤠
@30guarino
@30guarino 2 жыл бұрын
I haven't been able to finish it because I catch myself going on autopilot lol
@RobertHolzapfel
@RobertHolzapfel 2 жыл бұрын
Lots of tutorials out there focus only on basic stuff, but you, Nick you teach the more advanced stuff. Really appreciate that! Thanks very, very much! Just subscribed to your channel.
@dev_jeongdaeri
@dev_jeongdaeri 2 жыл бұрын
your content is like a gold mine!!!
@SwiftfulThinking
@SwiftfulThinking 2 жыл бұрын
Thank you 정대리!
@enriqueavina6827
@enriqueavina6827 2 жыл бұрын
Incredible tutorial! The pace & quality is perfect! THANK YOU!
@roshanthapa25
@roshanthapa25 Жыл бұрын
The whole series is awesome... love how you come up with the use cases for each topic
@shadowseekerme
@shadowseekerme 2 жыл бұрын
No doubt the explanations on each of the series have been magnificent :) and gone inside such easily and fast.
@josemanuelortizsanchez4983
@josemanuelortizsanchez4983 Жыл бұрын
Very interesting to be able to customize the behavior of our titles or to be able to know if an object is on the screen or not, how much scroll has been done in the view, etc. Thank you!
@user-of4vx1vo7j
@user-of4vx1vo7j Жыл бұрын
ניק אתה תותח הסברים ממש ברורים קצרים וקולעים תודה רבה לך ממדינת ישראל !!!!
@andrejkling3886
@andrejkling3886 2 жыл бұрын
Thank you so much Nick... Awesome examples and very powerful tool. Thank you for sharing your knowledge. Keep going . Energy and persistence overcome obstacles.
@SwiftfulThinking
@SwiftfulThinking 2 жыл бұрын
Thanks Andrej :)
@TheSpiralnotizblock
@TheSpiralnotizblock 2 жыл бұрын
This is what I needed. Really good examples! Didn't know that this even existet!
@sondoskannous3306
@sondoskannous3306 Жыл бұрын
It's really new information for me. Thanks alot
@bruhmoment3731
@bruhmoment3731 2 жыл бұрын
Very well explained! Thank you!
@priceringo1756
@priceringo1756 2 жыл бұрын
Top notch opening and introduction. :)
@SwiftfulThinking
@SwiftfulThinking 2 жыл бұрын
Thanks :)
@magedmohmed4403
@magedmohmed4403 9 ай бұрын
Thanks a lot nick , you are perfect in explanation
@kdtechniquesofficial6153
@kdtechniquesofficial6153 Жыл бұрын
Loved it... 😍
@ugolafosse3267
@ugolafosse3267 2 жыл бұрын
Bro you are my favorite teacher by faaar! I would definitively buy a Course from you about building Really Advanced production app using the latest SwiftUI Features (async await sequence complex filtering, MapKit, CoreKit and professional animations just to give you some ideas). In the meantime keep up the excellent work.
@SwiftfulThinking
@SwiftfulThinking 2 жыл бұрын
Thanks Ugo! I definitely want to do a bigger app soon. I'll keep those in mind.
@mylaluna
@mylaluna 10 ай бұрын
Thank you for the tutorial.
@touschflorian1679
@touschflorian1679 2 жыл бұрын
Amazing like always. You're a great teacher 🥵
@muncho404
@muncho404 Жыл бұрын
Nice work💕
@KimbrellBrad
@KimbrellBrad 2 жыл бұрын
Will need some review but this is very powerful! Likely several reviews LOL!
@SwiftfulThinking
@SwiftfulThinking 2 жыл бұрын
Thanks again Brad!
@OBLIVIOUSKARI
@OBLIVIOUSKARI Жыл бұрын
This video was amazing thank you
@anthneyjane1097
@anthneyjane1097 2 жыл бұрын
as always Nick your the man! would you consider fully using preferencekeys for any communication back to parent, as an alternative for bindings? or is there a performance cost
@SwiftfulThinking
@SwiftfulThinking 2 жыл бұрын
I don’t think there’s much of a performance cost here. Bindings are better if the value will keep changing, while the preference key will be set only once per init. The problem with these PreferenceKeys is that they are environment variables so multiple views could be writing and overwriting to them. You also need to create a custom Key and observe the key for every value you create. I use these sparingly, usually only when I find a Binding isn’t scalable. Well use these in the next 2 videos so you’ll see some real world examples!
@nalinporwal1446
@nalinporwal1446 Жыл бұрын
Bro I love you. You teach me like Hell... ❣
@5thgenapps608
@5thgenapps608 2 жыл бұрын
Hey... you are definitely one of the best teachers i have ever encountered . I am having great great difficulty with the Apple Sign in in the instagram course, it seems your method is outdated . I'm trying here because no response in the Q&A section. Can you please do a tut on Firebase apple sign in if possible. Thanks very much for all your efforts.
@SwiftfulThinking
@SwiftfulThinking 2 жыл бұрын
Hi, sorry about that. The DogGram course is a bit deprecated now. I will be covering Firebase on this channel soon!
@5thgenapps608
@5thgenapps608 2 жыл бұрын
@@SwiftfulThinking i solved the issue an posted solution in course for anyone else who may have same issue.
@franklemur5518
@franklemur5518 Жыл бұрын
WOW - This is quite confusing. I liked your reply to Ago re using Bindings unless not scaleable. Any reason you wouldn't use the environmental variable technique?
@SwiftfulThinking
@SwiftfulThinking Жыл бұрын
Environments update from parent to child.. this is the reverse, a child view trying to update the parent’s value
@LM-bn1wt
@LM-bn1wt 8 ай бұрын
Very good but it is very difficult to retype everything on Xcode when we want to experiment with that. Please make the projects available for your videos! Thanks
@LM-bn1wt
@LM-bn1wt 8 ай бұрын
Related to this preferenceKey... isn't easier to create a @State variable in the parent and pass a binding to the children? I agree that if you have 3 child views, one inside another, the preferenceKey will be "easier"
@paulancajima
@paulancajima 2 жыл бұрын
thank you
@tmjromao
@tmjromao 2 жыл бұрын
Hi Nick, learning a lot with your videos. You explain very well and most important put yourself on the beginner shoes. A doubt about PreferenceKey, is it possible to have more than 1 key? e.g. implement all the three use cases you explain on a single app? many thanks, best regards
@SwiftfulThinking
@SwiftfulThinking 2 жыл бұрын
Glad to hear that Tiago! Yes, you can create as many PreferenceKeys as you want in your app. I often will have 1 for SafeArea, 1 for ScrollViewOffset, and maybe 1 for reading location of an object. The thing to keep in mind is that when setting the values for the PreferenceKey, it overwrites the previous value. So generally, you justdon't want two different functions on the same screen to be updating the same PreferenceKey. (I hope that make sense? lol)
@tmjromao
@tmjromao 2 жыл бұрын
@@SwiftfulThinking it doesn't (yet, lol) but thanks for the reminder. It would be good if you could do/show how to do an app with all these things you explain, i.e. another todo app :)
@emadisaac7052
@emadisaac7052 8 ай бұрын
can I use PreferenceKey to set the height of TabView according to the content of it's Childs , because if I put tabView in ScrollView I have to specify the height of the tabview otherwise the tabview will not appear
@SwiftDeveloperWorld
@SwiftDeveloperWorld 11 ай бұрын
if we want to use Background again to assign another background , what will happen?
@ncba
@ncba Жыл бұрын
5:45 if your value does not update remove the "value = nextValue()". For some reason the initial code stopped working until you remove that.
@karljay7473
@karljay7473 2 жыл бұрын
Thanks for the tutorials, do you have a link to the code?
@SwiftfulThinking
@SwiftfulThinking 2 жыл бұрын
Hi Karl, the code will be posted on my Github once I finish recording the playlist (about 1 week from now) github.com/SwiftfulThinking
@jemmytech5474
@jemmytech5474 2 жыл бұрын
Why Does SwiftUI ScrollView Return To Top but not to the point from where I started/clicked? can I control this with the prefernceKey or geometry reader?
@vladimirmoor
@vladimirmoor Жыл бұрын
You can use ScrollView Reader - there is some lesson in this course here.
@jemmytech5474
@jemmytech5474 Жыл бұрын
@@vladimirmoor please link me there
@vladimirmoor
@vladimirmoor Жыл бұрын
@@jemmytech5474 kzfaq.info/get/bejne/kNF_qadk1NGleqM.html
@SwiftDeveloperWorld
@SwiftDeveloperWorld 11 ай бұрын
why is it static?
@ncba
@ncba 2 жыл бұрын
15:25 thats one funny solution 😆 I dont know why I laughed
@SwiftfulThinking
@SwiftfulThinking 2 жыл бұрын
😅
@ncba
@ncba 2 жыл бұрын
@@SwiftfulThinking thanks for the detailed tutorial, opened up some pretty neat features for my app
@user-eb7ne5ii1r
@user-eb7ne5ii1r 2 жыл бұрын
Why can not I use state/binding simply?
@dearly_bel0ved
@dearly_bel0ved 2 жыл бұрын
你的名字和我一样
@chetandhowlaghar5166
@chetandhowlaghar5166 Жыл бұрын
got the same question. did you find the answer?
@user-ub1wn7yt1d
@user-ub1wn7yt1d 2 жыл бұрын
can you share code please?
@SwiftfulThinking
@SwiftfulThinking 2 жыл бұрын
All source code is posted to my github! github.com/SwiftfulThinking
@vitolom6578
@vitolom6578 2 жыл бұрын
Hey then discord group?
@SwiftfulThinking
@SwiftfulThinking 2 жыл бұрын
Discord is LIVE! discord.gg/vhKKyYTGDb
Create a custom tab bar in SwiftUI | Advanced Learning #11
52:05
Swiftful Thinking
Рет қаралды 33 М.
How to use @ViewBuilder in SwiftUI | Advanced Learning #9
24:01
Swiftful Thinking
Рет қаралды 25 М.
WORLD'S SHORTEST WOMAN
00:58
Stokes Twins
Рет қаралды 131 МЛН
Я обещал подарить ему самокат!
01:00
Vlad Samokatchik
Рет қаралды 9 МЛН
Получилось у Миланы?😂
00:13
ХАБИБ
Рет қаралды 6 МЛН
Stop, Intel’s Already Dead!
13:47
Linus Tech Tips
Рет қаралды 216 М.
Magnus Carlsen, Hans Niemann Drama Just Got Much Worse
31:16
GothamChess
Рет қаралды 392 М.
How to use Dependency Injection in SwiftUI | Advanced Learning #16
35:32
Swiftful Thinking
Рет қаралды 27 М.
How to use @EnvironmentObject in SwiftUI | Bootcamp #51
26:48
Swiftful Thinking
Рет қаралды 37 М.
Modding TikTok to only show Cat Videos
29:12
Bryce Bostwick
Рет қаралды 91 М.
Мок-собеседование iOS разработчика
1:17:34
iOS Такой • IOS Разработка • IT Подкасты
Рет қаралды 10 М.
How to use Protocols in Swift | Advanced Learning #15
28:37
Swiftful Thinking
Рет қаралды 15 М.
How to use KeyPaths in Swift | Advanced Learning #29
25:12
Swiftful Thinking
Рет қаралды 3,3 М.
The moment we stopped understanding AI [AlexNet]
17:38
Welch Labs
Рет қаралды 860 М.
WORLD'S SHORTEST WOMAN
00:58
Stokes Twins
Рет қаралды 131 МЛН