SwiftUI Tutorial: What's the difference between @State, @ObjectBinding, and @EnvironmentObject?

Sdílet
Vložit
  • čas přidán 19. 05. 2024
  • If you want to understand how SwiftUI works with state, start here - this video walks you through how state works, why it matters, and how each of SwiftUI's state options work, all using hands-on code examples so you can see for yourself.
    For more information on SwiftUI, see my free online book SwiftUI By Example: www.hackingwithswift.com/quic...
  • Věda a technologie

Komentáře • 238

  • @twostraws
    @twostraws  Před 4 lety +9

    Watch next: How to fix slow List updates in SwiftUI - czcams.com/video/h0SgafWwoh8/video.html
    Questions? Comments? Tweet me @twostraws.

  • @simonbachmann2120
    @simonbachmann2120 Před 4 lety +266

    IMPORTANT: ObjectBinding/BindableObject are deprecated now! @ObjectBinding is become @ObservedObject and BindableObject protocol is become ObservableObject as well as willChange become objectWillChange.

    • @niklasnickel
      @niklasnickel Před 4 lety +3

      Simon Bachmann Thank you so much! This indeed saved a lot of trouble...

    • @sreekumarmenon
      @sreekumarmenon Před 4 lety

      Was going to ask the same, I started swiftui recently and was confused with seeing ObjectBinding in this video! thanks

    • @MattiaRighetti
      @MattiaRighetti Před 4 lety +1

      I was going to ask when to use ObservableObject and BindableObject, thanks! 😊

    • @flexmcpee
      @flexmcpee Před 3 lety

      Ah that makes sense. Only started learning SwiftUI of late and was confused seeing those. Thanks for clearing up.

    • @LazarofShalev
      @LazarofShalev Před 3 lety

      thank you 👌

  • @abcd123906
    @abcd123906 Před 3 lety +34

    If you are learning SwiftUI, you literally NEEEEED to watch this video! This scratched so many cognitive "itches" I had about Swift, it's almost scary. Thank you, thank you, thank you!

  • @JVancity
    @JVancity Před 4 lety +1

    Been messing around with all three for a few days now, getting things to 'work'! This video really hit the nail on the head and now I truly understand the why. Thanks Paul, you're a legend :)

  • @marlhex6280
    @marlhex6280 Před rokem

    Please make more! I love the way you talk with passion and interest! Also the way you edit the videos with a final touch! Awesome job!!!

  • @dhavalnena7386
    @dhavalnena7386 Před 4 lety +1

    Every time I watch your videos it gives me a deeper understanding of the topic explained. Thank you so much!

  • @AndreaCiani
    @AndreaCiani Před 3 lety +1

    This is the best video about this things I have ever watched. You make simple and more complicated examples and you describe them extremely well. Congrats and thanks!

  • @frimpongopokuagyemang8052

    Saying that this video is "HELPFUL" would be an understatement. However, I have no bigger words. LOL! In short, THANK YOU DUDE! The way you make things clear, is just something else.👌👌👌👌👌

  • @JellyLancelot
    @JellyLancelot Před 4 lety

    These videos are soooooo good. Your teaching style is amazing and easy to follow, but not slow enough that I'm skipping around for the info. Clear, concise and concentrated. Superb! Also, you explain the WHY. It's so important, but what so many people miss.

  • @koz
    @koz Před 4 lety +8

    Absolutely great stuff. You're making my Swift-learning experience a lot clearer.
    I'm intrigued about "who taught you?" though.
    Because I get the feeling you had a good teacher.
    (This is where you say you're self-taught too)

  • @uberunix
    @uberunix Před 3 lety +1

    This is an absolutely fantastic explanation for someone like me who doesn't know enough yet to distinguish the significant bits of what the docs are saying. Thank you so much! :D

  • @BroadcastYOzZelf
    @BroadcastYOzZelf Před 4 lety +1

    I'm used .Net's, old Xaml's and to Qt Qml's (super elegant) property bindings. I was exactly looking for an intro on how SwiftUI does this. You found the perfect level between giving an overview and going into detail. Thanks!

  • @nexplusedinburgh5545
    @nexplusedinburgh5545 Před 4 lety +4

    Wow! Best SwiftUI video in the whole CZcams! Thank you!

  • @coolisfoolable
    @coolisfoolable Před 3 lety +1

    This is THE best tutorial I've seen so far! And boy I've seen many.
    Thanks Paul!

  • @MatthewCawley
    @MatthewCawley Před 4 lety +1

    I've watched a few different videos on @State, @ObjectBinding and @EnvironmentObject and it didn't make that much sense. Your explanation was amazing, clear and high descriptive. Great job :)

  • @kevin-u7719
    @kevin-u7719 Před 2 lety

    I have saved 1 hour while watching you 20 minutes concrete and robust explanatory video. Thank you Paul.

  • @JacksMacintosh
    @JacksMacintosh Před 4 lety +3

    Oh my goodness. This @EnvironmentObject thing might just save my life. Thank you thank you!

  • @Nicolas-is3gq
    @Nicolas-is3gq Před 4 lety +1

    Excellent tutorial, I finally understand these concepts after trying a few other sources. Thanks Paul!

  • @wizzards44
    @wizzards44 Před 4 lety

    Paul you are smashing it again!!! Great breakdown of new tools!!!

  • @oliverbarreto1838
    @oliverbarreto1838 Před 4 lety +6

    Great great tutorial... first division university class... core concepts really well explained and introduced vía telling an incremental story... a must watch... Apple should absolutely use this video and upload it to SwiftUI developer library
    💪🏻😀😎

  • @ac12484
    @ac12484 Před 2 lety

    Best no bs intro (experienced programmer here)

  • @marcoespinoza3327
    @marcoespinoza3327 Před 4 lety

    Stumbled upon your tutorials and explanations and it’s amazing. I am currently doing QA work and do some dev work too as I’m learning. However, this is preparing me for the future and I really appreciate your videos and explanations. I still want to transition from QA to dev because it’s more interesting but I know I have a while to go.

  • @brandonr.8784
    @brandonr.8784 Před rokem

    Been stuck on these concepts for days, this video really help improve my understanding!

  • @Mriceman2002
    @Mriceman2002 Před 4 lety

    You explain very easily even without the help of your two
    dogs :) You are the best ! Hope you continue to make many more videos!

  • @piyushgeorge1847
    @piyushgeorge1847 Před 4 lety

    Best tutorial for the states. Loved it

  • @PeterPurmonen
    @PeterPurmonen Před 4 lety +2

    Excellent! All gaps flled. Thank you. 👍🏻

  • @chrisual
    @chrisual Před 3 lety +3

    Much of this video is not appropriate anymore, but the description of what state, binding, etc are is TOTALLY worth watching. I have watched so many videos, but this is the first time I have understood these concepts. Well done Paul!!

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

      I’m just getting started. What would you recommend is the perfect video right now for this information? Thank you very much.

  • @1sndct
    @1sndct Před 3 lety

    Great explanation, been trying to grasp this concept for a loooooong time, its finally coming together. Thank you

  • @fortune1109
    @fortune1109 Před 4 lety

    Hi Paul, thank you for the tutorials you are making. Helps me alot.

  • @littletalk8860
    @littletalk8860 Před 4 lety +3

    Great explanation, love your professional tutorial

  • @ZoeSummers1701A
    @ZoeSummers1701A Před rokem

    I think this is the best tutorial video you’ve ever made.

  • @dlbYT8
    @dlbYT8 Před 2 lety

    Your content is gold. Thanks Paul!

  • @torcelly
    @torcelly Před 2 lety

    Hi Paul. Thank you for this awesome video. Excellent tutorial. Your explanation is accurate, concise, and clear. Congrats!

  • @thealchemist1480
    @thealchemist1480 Před 4 lety

    This is well described and very helpful video indeed. Keep the good work up,,, you are doing a commendable job for the community.

  • @yixe2253
    @yixe2253 Před 4 lety

    You're a great teacher, easy to understand.

  • @francescofuscaldo2364
    @francescofuscaldo2364 Před 4 lety +1

    Great videos, thank you so much. I'd like to suggest you a subject for the next videos, it would be great to see how to work with CoreData and SwiftUI!

  • @niklasnickel
    @niklasnickel Před 4 lety

    Thank you very much! This was the first time I really understood what was going on...

  • @dimiutube
    @dimiutube Před 4 lety

    Thanks for the great explanation, Paul! Now most of the magic behind SwiftUI is much clearer for me :-)

  • @tomtubbs6254
    @tomtubbs6254 Před 4 lety +1

    Thanks Paul - great visuals for the video along with your clear instruction.
    +1 for the request for a basic Swifty I app that uses core data.

  • @marcaupont9145
    @marcaupont9145 Před 4 lety

    Great vid!! Love the explanations!

  • @oneminuteswift1072
    @oneminuteswift1072 Před 4 lety +2

    I love SwiftUI n I love this Tutorial too. This is awesome.

  • @egormerkushev
    @egormerkushev Před 4 lety +1

    Thank you for this tutorial!

  • @olepetersen4460
    @olepetersen4460 Před 3 lety +3

    You make really great videos, and thank you for that. Regarding this one: My projects have no SceneDelegate, so an update would be highly appreciated. Where and how do you set up the global varible in the .app file?

  • @rickstrickland2464
    @rickstrickland2464 Před 4 lety +64

    Your clarity is awesome. Can you do one that uses Core Data?

    • @alihodroj9559
      @alihodroj9559 Před 4 lety

      maybe he already did one go check : )

    • @rickstrickland2464
      @rickstrickland2464 Před 4 lety +6

      Core Data with SwiftUI

    • @alihodroj9559
      @alihodroj9559 Před 4 lety

      @@rickstrickland2464 oh now i get it : )

    • @brunofulber4688
      @brunofulber4688 Před 4 lety +2

      I wasn't able to make it work too, got to figure a good way to make managed objects conform to bindableObject

    • @stephencollins2831
      @stephencollins2831 Před 3 lety

      I’ve been an iOS dev for 1 week :) i think you can pull initial startup data out of core data in the scene delegate. Then pass that data into EnvironmentObjects so it can be accessible to all child view from main. Then each sub view can perform CRUD operations on it with core data. This method may not be great if you’re pulling a lot of data into memory. Perhaps there is a better way? Would love to hear!

  • @guitaripod
    @guitaripod Před 4 lety

    Now this now a year later, it's so clear. Thanks

  • @shivammahendru6122
    @shivammahendru6122 Před 3 lety

    Much needed explanation!! Thanks Paul

  • @di_nerd_apps
    @di_nerd_apps Před 4 lety

    BEST EXPLANATIONS !! BIG UP!!!

  • @petersuvara
    @petersuvara Před 4 lety

    Paul, we generally keep state as a completely different place to the UI components themselves, this provides a layer between state/transport and UI.

  • @koustav2008
    @koustav2008 Před 4 lety

    EXCELLENT Explanation !!!

  • @readmore2019
    @readmore2019 Před 4 lety +1

    ~AMAZING~ This is SOOO helpful!!!

  • @greggy16d
    @greggy16d Před 4 lety +3

    This is priceless. Thank you

  • @robertsan2654
    @robertsan2654 Před 4 lety +1

    Being an iOS & React developer feels great with SwiftUI. :)

  • @triXtyle
    @triXtyle Před 6 měsíci

    Amazing video, teaches us core concept in a very good way. BUT The Victor Hugo reference nailed it!!!

  • @SehajChawla
    @SehajChawla Před 4 lety +3

    Love all your tutorials. Would be great to have in depth tutorials on Combine framework as well.

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

    Great video @twostraws very well explained and delivered! Time to write some SwiftUI...

  • @limtc
    @limtc Před 4 lety

    This is the best explanation so far! However, I do hope you can add in explanation of @Binding besides these 3.

  • @alexanderfitterling
    @alexanderfitterling Před 3 lety

    Thank you so much for this video. You have amazing good teaching skills!

  • @lvkd_
    @lvkd_ Před 4 lety

    Awsome Teacher.. thank you for your great lecture

  • @ismailtosun3621
    @ismailtosun3621 Před 4 lety

    Thatks for this cool video ! Great explanation.

  • @farukenstein
    @farukenstein Před 4 lety +1

    "please just stop and thnik for one moment how amazing that is" is the one possible definition when it comes to swiftui.

  • @andrevdw747
    @andrevdw747 Před 3 lety +1

    What a clear explanation! Thanks! Also understandable for a beginner like me :-)

  • @user-xe4qm5bn6i
    @user-xe4qm5bn6i Před 4 měsíci

    Just learning Swift.. this was really helpful. And I caught your bread and 24601 reference… Cheers for that one!!! 🥃

  • @vipullal7689
    @vipullal7689 Před 3 lety

    Loved it! Clear tutorial.

  • @ChristianLeovido
    @ChristianLeovido Před 4 lety

    Thank you so much, your explanation of these concepts is very clear

  • @arkemal
    @arkemal Před rokem

    I've learned a lot from this. Thank you!

  • @AttilioPatania
    @AttilioPatania Před 4 lety

    thanks so much for this explanation, it works well to understands the way these annotations works, also if now the Object binding pattern is changed since the video was @published :)

  • @kaljsdlksjfd3286
    @kaljsdlksjfd3286 Před 4 lety

    Thank you! Great work

  • @sergehulne
    @sergehulne Před 3 lety

    Excellent tutorial! Thanks!

  • @alondob
    @alondob Před 4 lety

    Great explanation!

  • @MeteoraEra
    @MeteoraEra Před 4 lety

    Your videos are awesome man.

  • @SteemeX
    @SteemeX Před 4 lety

    You are cool! Total covering, thanks a lot

  • @shivaskanthan6144
    @shivaskanthan6144 Před 4 lety

    Excellent explanation!

  • @nirb16
    @nirb16 Před 3 lety

    Great explanation! Thank you

  • @haraprasadsenapati6662

    Awesome video Paul

  • @kimtipatel7
    @kimtipatel7 Před rokem

    U r superb explaining ❤

  • @farkhodkh2760
    @farkhodkh2760 Před rokem

    This is Great! Thank you Paul

  • @max500k
    @max500k Před 3 lety

    Awesome video, super concise!

  • @muzikjay
    @muzikjay Před 2 lety

    Thank you so much for this!!

  • @cularu1
    @cularu1 Před 4 lety

    Very cool! Much simpler than managing state in android.

  • @sajjadkharrazi6370
    @sajjadkharrazi6370 Před 4 lety

    fantastic tutorial. great

  • @24Doggi
    @24Doggi Před 3 lety

    Nest video for a guy who comes from java and python. Thanks!

  • @SudaraF
    @SudaraF Před 4 lety

    Very good explanation, learnt a lot 👍

  • @olepetersen4460
    @olepetersen4460 Před 3 lety

    Another great video - thank you.

  • @chillybean9662
    @chillybean9662 Před 4 lety

    tchai! that was clear and refreshing.

  • @idembele
    @idembele Před 4 lety

    5:46 beautiful example on how @State keyword works

  • @TK-tg1hx
    @TK-tg1hx Před 3 lety

    You are really brilliant smart.... What a wonderful explain!? Thank you sooooo much!

  • @kimsaypov162
    @kimsaypov162 Před 3 lety

    Great explanation. Thanks.

  • @rickywitherspoon2861
    @rickywitherspoon2861 Před 4 lety

    Awesome tutorial

  • @ps1kx
    @ps1kx Před 4 lety

    Awesome explanations! Nothing else to say :-D

  • @viettrungphan9770
    @viettrungphan9770 Před 4 lety

    Thanks for your tutorial

  • @mistermagic4507
    @mistermagic4507 Před 3 lety

    Finally my company decided to start the next project using SwiftUI on iOS 13 and here I am, BOOOM :)

  • @ankitthakur85
    @ankitthakur85 Před 4 lety

    These clarity is awesome. Could you please re-visit this again, once GM release happened for iOS 13. As the Combine framework is also in beta, and could have changes before GM release happens in September/October month.

  • @pbalinov
    @pbalinov Před rokem

    Great video! Thank you!

  • @anandmishra3926
    @anandmishra3926 Před 3 lety

    Love❤️ this Video.

  • @SudipBhattacharyya
    @SudipBhattacharyya Před 3 lety

    Excellent. Thank you so much ☺️☺️👍

  • @corruptscorpion
    @corruptscorpion Před 4 lety

    Hi Paul, love your videos. I have a question regarding spriteKit, now that swiftUI is here, what happens to spritekit logic? Has that changed too, how do we use it now with all this new code logic?

  • @jacks-projects5238
    @jacks-projects5238 Před 3 lety

    This is a superb video.

  • @hilalalhakani9139
    @hilalalhakani9139 Před 3 lety

    Great explanation

  • @drinkitapp8121
    @drinkitapp8121 Před 4 lety +1

    3:59 is my favourite part of the the video 🤯

  • @jimscodecorner5108
    @jimscodecorner5108 Před 2 lety

    Great video! Thank you