Data Flow in a SwiftUI App

Sdílet
Vložit
  • čas přidán 31. 05. 2024
  • In this lesson I want to review with you how data both plays a part in your view and also how it flows through your app across multiple views.
    We’ll start with the simplest scenario and work our way to more complex scenarios.
    You’ll see examples using state properties, bindings, observable objects, environment objects as well as other data related SwiftUI keywords such as @Published, @ObservedObject and more.
    By the end, you’ll know how to pass data around in your SwiftUI app!
    🚨 SPECIAL CWC+ OFFER FOR CZcams:
    cwc.to/youtubeoffer
    Timestamps:
    00:00 Introduction
    00:57 SwiftUI State Properties
    03:20 State Properties Recap
    03:38 SwiftUI Bindings
    04:10 $Binding Example
    06:51 $Bindings Recap
    07:05 @Binding Example
    14:42 $Binding and @Binding Recap
    15:15 SwiftUI State and Bindings Recap
    15:45 SwiftUI ObservableObjects
    17:31 ObservableObject Example
    22:55 ObservableObject Recap
    26:33 SwiftUI EnvironmentObject
    28:07 EnvironmentObject Example
    30:28 EnvironmentObject Recap
    32:39 Outro
    MY FREE ONLINE COURSE:
    ⚡ How to make an app in 14 days - cwc.to/14days
    CWC+ PROGRAM:
    👩‍💻 All our courses in a learning path - cwc.to/plus
    WEEKLY UPDATES VIA EMAIL:
    ✉️ Every Saturday, receive an email digest of new content - cwc.to/newsletter
    CONNECT:
    🌍 Website - codewithchris.com
    😺 GitHub - github.com/codewithchris
    📸 Instagram - / codewithchris
    🐦 Twitter - / codewithchris
    ABOUT CODEWITHCHRIS:
    Hi I’m Chris! I’m dedicated to teaching fundamentals about how to make an app. This is important if you’re trying to land an iOS job, be a freelancer, increase or start a business with an app idea. On this channel and my website, you'll find a ton of free resources and tutorials to aid you on your journey to learn iOS development. Many people have learned to code and build apps on their own! cwc.to/reviews
    DID THESE LESSONS HELP YOU?
    Please let me know! - feedback.codewithchris.com
    ROADMAP:
    roadmap.codewithchris.com

Komentáře • 145

  • @F34R303
    @F34R303 Před měsícem

    I started watching your videos 6 years ago when I was in high school to learn coding. Now, I've graduated college, working as a software engineer and am still learning a ton from your videos!

  • @ammarmujib
    @ammarmujib Před rokem +5

    The video seems to be 1 year old, but still masterpiece to understand data flow/proprty wrappers in SwiftUI. Thanks a lot for such simple and clear explanation.

  • @JacobSucksAtCode
    @JacobSucksAtCode Před 11 měsíci +5

    Dude your walkthroughs are so good. Super thorough, relaxing and information filled!

  • @andriybelizky9318
    @andriybelizky9318 Před 5 měsíci

    Great video - I love it how it shows different scenarios and various tools used to solve issues

  • @shrutisharma3341
    @shrutisharma3341 Před 2 lety +5

    This video deserved so many more likes. This literally cleared out all of my data flow confusions with swift UI! Thanks a ton!!

    • @CodeWithChris
      @CodeWithChris  Před 2 lety +1

      Ahhhh, thank you so so much! Makes all the hard work so worth it. :) -Arthur

  • @mario_luis_dev
    @mario_luis_dev Před 3 měsíci +1

    masterful explanation Chris! 👏

  • @nindz9272
    @nindz9272 Před 2 lety +2

    Thank you so much for this video! Just yesterday I was googling the exact things you've described in this video. It really does help to understand how things work in SwiftUI.

    • @CodeWithChris
      @CodeWithChris  Před 2 lety

      Glad you found us. We're so excited for you! :) -Arthur

  • @armaanr1656
    @armaanr1656 Před 2 lety

    This cleared up all of my confusions. Best tutorial on youtube. Keep it up Chris🙂!

    • @CodeWithChris
      @CodeWithChris  Před 2 lety

      This comment made our day. Thanks for learning with us! -Arthur

  • @SebastienBarrau
    @SebastienBarrau Před rokem +1

    Thanks for the awesome video on environmentObjects. You made it super easy to understand and I appreciate the time and effort you put into making it. Keep up the great work!

    • @CodeWithChris
      @CodeWithChris  Před rokem

      Thank you so much for the kind words! :) - Pat

  • @zlatkoiliev8927
    @zlatkoiliev8927 Před rokem

    I finally managed to understand them all! Thank you so much for this tutorial Chris! You are awesome! :)

    • @CodeWithChris
      @CodeWithChris  Před rokem

      We're happy to help! And thanks for watching! :) - Pat

  • @GamingSucks
    @GamingSucks Před 2 lety +8

    What an incredibly clear explanation. The examples really bring it together. Quite possibly the best I have seen on CZcams!

    • @CodeWithChris
      @CodeWithChris  Před 2 lety +1

      Aaaaah, our team appreciates your support, Rick! Thank you for your very kind comment! :) -Arthur

  • @alvarovs89
    @alvarovs89 Před 2 lety +1

    Amazing, very well explained! thank you Chris!

  • @susantasahoo4702
    @susantasahoo4702 Před 2 lety +1

    Awesome video. This literally cleared out all of my data flow confusions with swift UI! Thanks a ton!! It deserves many more likes. Best video on this topic. Appreciate your effort for explaining it in nice & clean Manner.

    • @CodeWithChris
      @CodeWithChris  Před 2 lety

      Glad to hear this, Susanta! Thanks for learning with us! -Arthur

  • @PierluigiLuceri
    @PierluigiLuceri Před 9 měsíci

    thanks a lot, this is the best video about data flow in swiftui, great job

  • @arkemal
    @arkemal Před rokem

    Man, your explanations are excellent. Thank you for this!

  • @santoshlohar152
    @santoshlohar152 Před 9 měsíci

    Dude you explained in easy way..thanks.

  • @KimbrellBrad
    @KimbrellBrad Před 2 lety +8

    This was a very well-done explanation! Your style of walking through each combination of wrappers and properties really cleared up much of my previous "fuzzy" understanding of these property wrappers. Thanks Chris!

    • @CodeWithChris
      @CodeWithChris  Před 2 lety

      Thanks for your lovely feedback, Madd! Means a lot! -Arthur

  • @georgh.9814
    @georgh.9814 Před 2 lety

    Thank you so much! Exactly what i was searching for and so well descriped!.

  • @codingkim5714
    @codingkim5714 Před 2 lety

    Hi, Cris.
    Thank you for uploading these about Swift. I'd beed desperate till I found your channel. I found the best videos for starting to study the Swift! Awesome!

    • @CodeWithChris
      @CodeWithChris  Před 2 lety

      So kind of you! Thank you so so much! -Arthur

  • @DaveJacobseniOS
    @DaveJacobseniOS Před 2 lety

    Such quality explanations. Thank you as always!

    • @CodeWithChris
      @CodeWithChris  Před 2 lety

      Great to know this. Thank you for the kind words! -Arthur

  • @LTNKidd
    @LTNKidd Před rokem

    Very clear walk through, thanks Chris!

  • @user-om1ze4mi7u
    @user-om1ze4mi7u Před rokem +6

    This was an amazing video for developers who get stuck to understand how properties wrappers work. Besides, Your voice is so soft and your pronunciation is very clear which can mesmerize everyone. I already subscribed your channel.

    • @CodeWithChris
      @CodeWithChris  Před rokem

      Thank you for the kind words! Time for Chris to make a meditation app and to tell us to breathe, breathe, relax, breathe!
      @AdrienVillez

  • @jamesclavel25
    @jamesclavel25 Před rokem +1

    New with iOS app development and man, a lot of those property wrappers have been explained here which can easily be understood. Many thanks to you sir! Keep up the great videos - you've helped a lot of beginner devs here.

  • @nzbszb
    @nzbszb Před rokem +2

    This is very detailed, simplified and well explained. Others always tried (no offence!) but failed to give good examples like this. Thanks for this treasure.

    • @CodeWithChris
      @CodeWithChris  Před rokem +1

      Thank you for the kind words! We do our best to explain as simply as possible.
      @AdrienVillez

  • @3VAU
    @3VAU Před rokem

    Very nice and down to earth ;) thank you!

  • @balazskepli9471
    @balazskepli9471 Před 8 měsíci

    Very good summary on data flow! Thank you!

    • @CodeWithChris
      @CodeWithChris  Před 8 měsíci

      Glad it was helpful! Thanks for learning with us! - Iñaki

  • @joeybodnar
    @joeybodnar Před 2 lety +1

    I took your 2 initial iOS courses 6 years about back in 2015 and been working as a professional iOS dev for 5yrs now. came back to learn swiftUI. still high quality content, nice! wish I could like this video multiple times.

    • @CodeWithChris
      @CodeWithChris  Před 2 lety

      Aaaaah, your comment made our day. Thank you for learning with us! Your support means a lot! :) -Arthur

  • @ninumedia
    @ninumedia Před 2 lety

    Fantastic and clear explanation, thank you so much!

    • @CodeWithChris
      @CodeWithChris  Před 2 lety

      This comment made our day. Thank you so much, Nirdhar! :) -Arthur

  • @semilife
    @semilife Před 2 lety

    Thanks so much Chris as ever clear. Understand this clearly now.

    • @CodeWithChris
      @CodeWithChris  Před 2 lety

      Awesome, happy to know that we helped you! :) -Arthur

  • @40_pravalgautam15
    @40_pravalgautam15 Před 6 měsíci

    You made it easy to understand

  • @TheEmperorXavier
    @TheEmperorXavier Před 7 měsíci

    Your content is amazing

  • @jbare777
    @jbare777 Před 2 lety +1

    Thank you for this video, it was excellent. Liked and favorited!

    • @CodeWithChris
      @CodeWithChris  Před 2 lety

      Wow, you're just the best. We sincerely appreciate your support! :) -Arthur

  • @akshaykumar-qj2kx
    @akshaykumar-qj2kx Před rokem

    You are awesome teacher Chris :) Thank you for the valuable information.

  • @himanshukesharwani5333
    @himanshukesharwani5333 Před rokem +1

    Sir, this really helps me to understand concepts. Thank you for such a good video :)

  • @DJFabisLP
    @DJFabisLP Před 2 lety +1

    Wow, pretty informative and interesting! Thank you

    • @CodeWithChris
      @CodeWithChris  Před 2 lety

      Anytime! Thanks for learning with us! :) -Arthur

  • @sheetalshinde17
    @sheetalshinde17 Před rokem

    Thanks!!...Very well explained with example..

  • @uocnguyen5431
    @uocnguyen5431 Před rokem

    Great Tutorial, thanks for this!

  • @ClintonSiegel
    @ClintonSiegel Před rokem

    Very helpful! Thank you!

  • @yshlnhn
    @yshlnhn Před rokem

    Thanks a lot that makes me understand well about data flow

  • @thompsonms9941
    @thompsonms9941 Před 8 měsíci

    Good explanation bro ! Thanks !

    • @CodeWithChris
      @CodeWithChris  Před 8 měsíci

      Glad it was helpful! Thanks for watching! - Iñaki

  • @williamwildsmith5162
    @williamwildsmith5162 Před 2 lety

    Great job Chris!

  • @ThanhNguyen-jk5tn
    @ThanhNguyen-jk5tn Před 2 lety

    It's really helpful. Thanks!

    • @CodeWithChris
      @CodeWithChris  Před 2 lety

      Glad to know, thanks for learning with us! -Arthur

  • @michellemorgan6986
    @michellemorgan6986 Před rokem

    Thank you very much for this informative video! It was definitely very clear and simple, and I now have a better understanding of this topic (which I must admit, I was having a difficult time understanding)

    • @CodeWithChris
      @CodeWithChris  Před rokem

      This made our day. Thanks for learning with us! -Arthur

  • @huyle2838
    @huyle2838 Před 2 lety

    This is an awesome video. I feel so lucky to have access to this youtube channel.

    • @CodeWithChris
      @CodeWithChris  Před 2 lety +1

      Indeed! Thanks for learning with us! -Arthur

  • @sathriyansam727
    @sathriyansam727 Před 2 lety

    Wow super you just made my Sunday productive......👍🏻👍🏻🙂

    • @CodeWithChris
      @CodeWithChris  Před 2 lety

      We're glad that you found us, Sathriyan! :) -Arthur

  • @hakeemdeggs9117
    @hakeemdeggs9117 Před 10 měsíci

    Amazing!!!!!!

  • @nojarhead
    @nojarhead Před rokem

    Hi Chris, thanks for the excellent tutorial. Here's a couple of nuances that I've recently noticed in how @ObservedObject publishes changes and triggers redraws:
    1. if your Profile class had a second @Published property that is not used in the layout code, any changes to that property would trigger a redraw of the view anyways.
    2. setting the same/current value to a @Published property (e.g. isLoggedIn = true when it's already true) will trigger a redraw of the UI
    3. contrary to #2, the .onChange modifier will only react to new values and won't be triggered when setting the same value over and over

  • @hugge0948
    @hugge0948 Před rokem

    Such a good tutorial

  • @gpinto52
    @gpinto52 Před rokem

    excellent review

  • @alonavall08
    @alonavall08 Před rokem

    Wow thanks for this video now I understand...

  • @salmahassan8689
    @salmahassan8689 Před 2 lety

    Great Video .. Thanks :)

    • @CodeWithChris
      @CodeWithChris  Před 2 lety

      You are so welcome, subscribe for more! :) -Arthur

  • @weilingwang8331
    @weilingwang8331 Před 11 měsíci

    Thanks!

  • @petermartins2772
    @petermartins2772 Před 10 měsíci

    You're the the best

  • @srome0711
    @srome0711 Před rokem

    Great video

  • @kal5211
    @kal5211 Před 10 měsíci

    My man 👍

  • @SomwangIssaramala
    @SomwangIssaramala Před rokem

    Thank

  • @volimpia
    @volimpia Před 2 lety

    Thank you

  • @stephaniewagstaff6563

    How would I get what the user types in TextField over to another view. I can't seem to get use the property its held in to do so? Thank you.

  • @janstepnicka6553
    @janstepnicka6553 Před 10 měsíci

    Hello, thanks for your work. At 17:17 shouldn't the first line be @ObservedObject var myObj = MyObject() ?

  • @madoussfofana6045
    @madoussfofana6045 Před rokem

    Very very very Good explanation. Well done Chris. Tell me where do you collect those information as developper? When I read the Apple document without exemple. it's very hard to understand.

  • @dangerwang
    @dangerwang Před 2 lety

    Wow, this was super helpful Chris, thanks for putting this explanation together.
    Also, it sounds like you are using a custom mechanical keyboard, or maybe I'm wrong. What keyboard are you using?

    • @CodeWithChris
      @CodeWithChris  Před 2 lety +1

      Hi, Kevin! Thanks for your kind support! Kindly send an email to care@codewithchris.com so I can give you more info! The links are too long to share here, haha. :) -Arthur

  • @kevinvelasco1715
    @kevinvelasco1715 Před rokem

    I saw the video, great explanation, but I so simple, I'd like to know what happens if you need more than 1 enviormentObject. For instance, we have a model Company and model User that models are used in many parts of the app what is the correct way to pass 2 enviormentsObject and reuse that 2 models executed one time the user init session.

    • @CodeWithChris
      @CodeWithChris  Před rokem

      We suggest posting on our CodeCrew forum so that our tech support staff can help you. Just visit this link codecrew.codewithchris.com - Pat

  • @MiChElnumber4
    @MiChElnumber4 Před 2 lety

    Nice explanation Arthur!
    Is it possible to change an observable object in another class? I have my logic going on in a separate class and would like do make some changes in states viewable in the view file?

    • @CodeWithChris
      @CodeWithChris  Před 2 lety

      Hello, kindly post your question in our CodeCrew forum so that our tech support staff can assist you. Go here: codecrew.codewithchris.com. Thanks for learning with us! -Arthur

  • @matthewjura3377
    @matthewjura3377 Před 5 měsíci

    still great two years later

    • @CodeWithChris
      @CodeWithChris  Před 5 měsíci +2

      Glad it was helpful! Thanks for learning with us! - Iñaki

  • @nijeecooper621
    @nijeecooper621 Před 2 lety

    Hey Chris! Love the videos! I’m new to apps. Anyway you could make a series on how to make a app like Tik tok that let’s the users upload their videos?

    • @CodeWithChris
      @CodeWithChris  Před 2 lety

      Appreciate your support. Kindly post your idea here: app.productstash.io/codewithchris#/ideas Thank you! -Arthur

  • @user-vf2qm6ui5r
    @user-vf2qm6ui5r Před 10 měsíci

    I would KILL for you to teach Java, you're leagues better than my college professor.

    • @CodeWithChris
      @CodeWithChris  Před 9 měsíci

      Thanks for watching! I'll be sure to let Chris know :) - Iñaki

  • @nagarajvrao7249
    @nagarajvrao7249 Před 2 lety +2

    Plz include StateObject... In the follow up video

  • @shroomadelics
    @shroomadelics Před 2 lety +1

    Woow such great Tutorials. I already have done the Cardgame App 😊
    How do you proceed, if for whatever reason you want to create twice instances of Profile and use it with the property wrapper "EnvironmentObejct"?
    Would you have to create a constant for each instance (ex.: myProf1 = Profile () ) and then call the two references with the modifier EvnironmentObject?
    English is not my native language, hope you understood it anyway ^^

    • @CodeWithChris
      @CodeWithChris  Před 2 lety +1

      Hello, kindly post your question in our CodeCrew forum so that our technical support staff can assist you. Go here: codecrew.codewithchris.com/ Thank you! -Arthur

  • @rapier64
    @rapier64 Před 2 lety

    Hi Chris! I like your tutorials and I learnt a lot. But there is one more thing. I would like to integrate a print function for the AirPrint (SwiftUI). But unfortunately, I couldn't find any tutorials for this topic. Is it possible to integrate a printing function for SwiftUI at all? If yes, where could I find these information/tutorial? Thanks a lot. Peter🙂

    • @CodeWithChris
      @CodeWithChris  Před 2 lety

      Hello, kindly post this question in our tech support forum so that our tech support staff can assist you. Go here: codecrew.codewithchris.com. Thank you! -Arthur

  • @02244
    @02244 Před rokem

    What if I want to use 2 EnvironmentObjects of the same type? How do I specify the exact name of the variable in the root View?

    • @CodeWithChris
      @CodeWithChris  Před rokem

      We suggest posting on our CodeCrew forum so that our tech support staff can help you. Just visit this link codecrew.codewithchris.com - Pat

  • @alinamarrygeorge2630
    @alinamarrygeorge2630 Před 2 lety

    good

  • @sabalkatuwal8162
    @sabalkatuwal8162 Před rokem

    👍

  • @suchcodemuchwow
    @suchcodemuchwow Před rokem

    How do you reformat the code ?

    • @CodeWithChris
      @CodeWithChris  Před rokem

      Hi! We suggest posting your question on our CodeCrew forum. Our tech support staff will help you out. Just visit this link codecrew.codewithchris.com - Pat

  • @nindz9272
    @nindz9272 Před 2 lety

    A small typo in the slide on ~17:12. It should be "ObservedObject" instead of "ObservableObject" (although you said it correctly :D)

  • @rambabuguttula1500
    @rambabuguttula1500 Před 2 lety

    How can download the code with Chris phone or laptop and koputer

  • @joshuapaulhawthorne
    @joshuapaulhawthorne Před 2 lety

    What is a “View”

    • @CodeWithChris
      @CodeWithChris  Před 2 lety

      Hello, thanks for your kind words! Best if you post your question in our CodeCrew forum so that our tech support staff can guide you. Go here: codecrew.codewithchris.com. Thanks for learning with us! -Arthur

  • @Wiintb
    @Wiintb Před rokem

    You do a perfect job. But there is no way I can learn all from you. Need some more structure. Especially missing coredata.

    • @CodeWithChris
      @CodeWithChris  Před rokem

      You can get started here codewithchris.com/start :) - Pat

  • @AlynneTheFlorifant
    @AlynneTheFlorifant Před 9 měsíci

    At 17:17 you say @ObservedObject but the slide shows @ObservableObject. But man am I loving these breakdowns. Watching it right before an exam😅

    • @CodeWithChris
      @CodeWithChris  Před 9 měsíci +1

      🙈🤫 - just to make sure you were paying attention!
      @AdrienVillez