iOS 13 SwiftUI Tutorial: Interactively Transition and Share Data between Views with SwiftUI

แชร์
ฝัง
  • เผยแพร่เมื่อ 8 ต.ค. 2024
  • In this tutorial you are going to learn how to use State, ObservableObject and EnvironmentObject to share data between views and also how to transition between views using navigation link and sheet (modal transitions).
    ➡️ Project Files Start/Finish: / xcode-project-29511026
    ➡️ Tutorial on Property Wrappers: • iOS 13 Swift Tutorial:...
    ➡️ Tutorial on Combine: • iOS 13 Swift Tutorial:...
    🛒 GAME DEVELOPMENT COURSE - JUST $20 🛒
    www.udemy.com/...
    👏 Support me on Patreon: / brianadvent
    ➡️ Web: www.brianadvent...
    ✉️ COMMENTS ✉️
    If you have questions about the video or Cocoa programming, please comment below.

ความคิดเห็น • 54

  • @seccat
    @seccat 4 ปีที่แล้ว

    Thanks for keeping the subject up to date.
    thanks for covering for the ObservableObject (because of the deprecated BindableObject).

  • @eamiller
    @eamiller 4 ปีที่แล้ว +1

    This is AMAZING. Thank you so much for this. These data variables have been so confusing in every tutorial until now. So cool. Thanks for doing this man!!

  • @אנורסיאח
    @אנורסיאח 3 ปีที่แล้ว

    Thanks man, this video has been very helpful for me with my project that I'm working on. You are very well informed!

  • @santhoshVnair
    @santhoshVnair 4 ปีที่แล้ว

    Very nice, short & sweet, right to the point - no fluff. Thanks.

  • @ESquirez
    @ESquirez 3 ปีที่แล้ว

    Fantastic brain
    The way you explained this was spot on 👏🏿👏🏿👏🏿

  • @frankfernandez1957
    @frankfernandez1957 4 ปีที่แล้ว +3

    What an amazing explanation! Thank you so much, i have been having problems understanding this!!!

  • @mohitchaturvedi6088
    @mohitchaturvedi6088 4 ปีที่แล้ว

    Superb tutorial Brian, as always detailed video, described data transfer between views nicely. I always look forward to your videos and tutorials...Thanks!!

  • @kelvinjou4582
    @kelvinjou4582 4 ปีที่แล้ว

    This is the most straight to the point and relevant video for me! Thanks a million, ur content is awesome

  • @andrevdw747
    @andrevdw747 4 ปีที่แล้ว +1

    Great tutorial Brian! One of the few that explained also the WHY :-)

  • @BalaaLyf
    @BalaaLyf 4 ปีที่แล้ว

    Please upload one more video for this pass data.. Multiple labels and multiple textfields.. Data transfer and save it

  • @sebonnefoy
    @sebonnefoy 4 ปีที่แล้ว

    Thanks a lot, the most instructive video I've watched 😊

  • @hampussepe9487
    @hampussepe9487 4 ปีที่แล้ว

    this is by far the best video and explanation I've found so far on this subject! thanks for really digging in to it and keeping your examples on the topic and not just bake it in with 100 different things, a 1000 thanks and keep up the good work!

  • @_armtic
    @_armtic 5 ปีที่แล้ว +3

    watching this from Japan!

  • @GreenDevBabe
    @GreenDevBabe 5 ปีที่แล้ว

    Hi Brian. Please make small video about new BackgroundTasks. Because old doesn't work well anymore in Xcode 11.

  • @AlexCio
    @AlexCio 5 ปีที่แล้ว +2

    the animation looks smooth!

  • @kyoheo5326
    @kyoheo5326 4 ปีที่แล้ว

    You are so cool! thank you very much please more videos like this !!!

  • @xiaoyuhu4264
    @xiaoyuhu4264 5 ปีที่แล้ว

    Hi Brian, thank you for this amazing video! I love how your videos are always so comprehensive and straight forward. I would really love to see more content on Multi-peer connectivity framework(MCF) from you. Like a tutorial on how to use MCF to maybe transfer data, or even eventually interaction between different devices. I think if you make it into a series, it would be really cool!

  • @jersey-dude
    @jersey-dude 5 ปีที่แล้ว

    really quality content and very well explained. subbed on patreon. Thx for the content

  • @markaurelius61
    @markaurelius61 5 ปีที่แล้ว +1

    Very informative. It was not explained though how the environment variables declared in the views picked up the right value. They just seemed to be declared. Can you explain that?

    • @rebeloper
      @rebeloper 5 ปีที่แล้ว

      That is just the nature of @EnvironmentObject It's like a "singleton", but not really, there's more to it.

  • @sergiobost4891
    @sergiobost4891 3 ปีที่แล้ว

    Just what I needed! Thanks!

  • @bolivarbryan
    @bolivarbryan 5 ปีที่แล้ว

    Greetings from Colombia Brian. Thanks for sharing this content, Great work done here :-)

  • @ضدالظلم-د4ح
    @ضدالظلم-د4ح 4 ปีที่แล้ว

    You are amazing 😉
    It’s so Fantastic 😳👍
    Thank you so much ☺️

  • @thomascaster1911
    @thomascaster1911 4 ปีที่แล้ว

    I have two pickers and I would like to make a selection of these pickers and change the view with a click of a button.

  • @pickemparty
    @pickemparty 4 ปีที่แล้ว

    Can you do a tutorial that mirrors the wallet app where if you select the apple card or apple cash , the screen goes to full screen and doesnt do either of the two transitions you are showing in this tutorial?

  • @mukulbakshi28
    @mukulbakshi28 5 ปีที่แล้ว

    Great Content man, love it , very knowledgable.

  • @crazy9videos
    @crazy9videos 4 ปีที่แล้ว

    Great! suppose that the SecondView has another struct as ThirdView in the same class and how can we dismiss the sheet from ThirdView?

  • @rahuljamba5846
    @rahuljamba5846 2 ปีที่แล้ว

    Excellent !!!

  • @titoffen
    @titoffen 4 ปีที่แล้ว

    Great tutorial, thank you! However, how would you inject an object in Environment that conforms to a protocol? In other words, say we want to use a real network manager in production and a mock object for testing/development (which would retrieve the payload from a file in the app's bundle). Both classes would conform to a given protocol, but the trouble would appear when you declare the @EnvironmentObject. Which type should be specified? We cannot specify either class, because it could be either one. If we specify the protocol, we get a "Property type 'MyProtocol' does not match that of the 'wrappedValue' property of its wrapper type 'EnvironmentObject'". Any ideas?

  • @briefinsight8758
    @briefinsight8758 4 ปีที่แล้ว

    perfect! i liked it

  • @nurlankalybekov7336
    @nurlankalybekov7336 3 ปีที่แล้ว

    It would be much more interactive if you keep typing during video, instead of Copy/Paste-ing us ready code

  • @danielwatson6529
    @danielwatson6529 4 ปีที่แล้ว +1

    Yo Yo Yo, this helped me lots, however when i took the concept to my own project, everything worked, howver when i switched screens the bindable value vanished into thin air. how do i save this, and/or more specifically persist the new value to core date when the screen disapears.

    • @danielwatson6529
      @danielwatson6529 4 ปีที่แล้ว

      In reponse to the recent like to this comment. I i fixed it in this way, however it is not the way.
      what I did was create a function to persist to core data, and ran that function as my navigation switched views. That is all i needed for my project, however a more precise way, i think would be to have the instance of the observable object being called when an instance of your entity is created.
      This is easyish to do, however i am stuggling a bit because my structure is being defined in core data and i have no idea, or have found any tutorials that can help me figure out how to do this - please let me know if you guys find a solution

    • @danielwatson6529
      @danielwatson6529 4 ปีที่แล้ว

      Ok, so i fixed the issue. NSManagedObject conforms to ObservableObject. so i have an @Published property in there, which i assign as an empty string when i have a new entity created, then i linke textfields to it. feel free to pm me if you need further help

  • @danielbelemduarte
    @danielbelemduarte 4 ปีที่แล้ว

    @Brian, how to you handle and EnvironmentObject that needs to be updated after a JSON response. I'm setting the following error: "Publishing changes from background threads is not allowed; make sure to publish values from the main thread (via operators like receive(on:)) on model updates."

  • @rickywitherspoon2861
    @rickywitherspoon2861 5 ปีที่แล้ว

    At 8:50 you show that userData is passed from A to B. Can it then be passed from B to C or do you have to use an EnvirnomentObject? In this example the environment object would be better, but let’s say you have a view controllers A-H and only a A,B, and C need userData data. I’m having a hard time passing an observable object to more than one other view controller like you showed.

  • @sam2223
    @sam2223 5 ปีที่แล้ว

    Hello Brian
    I have a question and hope that you can help me. I have created a "single view" and made the first page. with a button I linked to the second page. if I activate the "assistant editor" on the second page it shows me "UIResponder.h" and not this one I have selected in "class".
    I hope for an answer. thanks

  • @nickng8069
    @nickng8069 5 ปีที่แล้ว +1

    SecondView seems to be asking for variable initializing down in the preview_ ???

    • @danielwatson6529
      @danielwatson6529 4 ปีที่แล้ว

      I just delete those bits and run the simulator, lazy i know but i dont really get it, you fix it?

  • @SHIVAMGUPTA-pb7ru
    @SHIVAMGUPTA-pb7ru 4 ปีที่แล้ว

    very clearly expalin

  • @demaupeoucorentin
    @demaupeoucorentin 5 ปีที่แล้ว

    Hey! In your last tutorial with Core Data (ToDoList app), I've a problem with the environment in SceneDelegate file. When you set the environment of the menu of the app, you add the code with Core Data. And for me, Xcode say some errors... Have an idea for don't have this?
    Code :
    let managedObjectContext = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext
    let contentView = ContentView().environment(ERROR HERE, managedObjectContext)
    window.rootViewController = UIHostingController(rootView: ContentView())

    • @danielwatson6529
      @danielwatson6529 4 ปีที่แล้ว

      try just "let context = (UIApplication..........
      im guessing you error might be a invalid redeclaration error?

    • @danielwatson6529
      @danielwatson6529 4 ปีที่แล้ว

      let context = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext
      let contentView = ContentView().environment(\.managedObjectContext, context)

  • @matthewross611
    @matthewross611 5 ปีที่แล้ว +1

    How does this interact with core data?

    • @rebeloper
      @rebeloper 5 ปีที่แล้ว +1

      Check out his other video about SwiftUI with Core Data: th-cam.com/video/-BZdQmHV4MQ/w-d-xo.html

  • @matthewperrault6390
    @matthewperrault6390 4 ปีที่แล้ว +2

    I HATE SWIFTUI. IT is STRAIGHT GARBAGE. 3 days now just to update an integer, then pass it over to another VC and print it. I couldn't understand/follow what you were saying, 1/2 of your project was already done, VERY frustrating. I know I build the same thing with storyboards in 5 minutes.

  • @MrVipulLal
    @MrVipulLal 3 ปีที่แล้ว +1

    Such a long video to explain a simple concept ,!!!!!

  • @edvardharnes4220
    @edvardharnes4220 3 ปีที่แล้ว

    Bad didaktik, zu viele themen vorher geshrieben....zb model

  • @pijushdebbarma7979
    @pijushdebbarma7979 4 ปีที่แล้ว +1

    It’s too long video and clumsy for beginners to get your idea in mind.

  • @YoureHot
    @YoureHot 2 ปีที่แล้ว

    I'm struggling. I'm trying to transfer an integer from one view to another, but I've spent days trying to find out with no luck. My end goal is to make is so that the player can see the score in the "gameOver" view. Anyone who knows how?

  • @אנורסיאח
    @אנורסיאח 3 ปีที่แล้ว

    Thanks man, this video has been very helpful for me with my project that I'm working on. You are very well informed!