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

Поделиться
HTML-код
  • Опубликовано: 12 дек 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

  • @santhoshVnair
    @santhoshVnair 4 года назад

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

  • @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!!

  • @seccat
    @seccat 4 года назад

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

  • @kelvinjou4582
    @kelvinjou4582 4 года назад

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

  • @frankfernandez1957
    @frankfernandez1957 5 лет назад +3

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

  • @ESquirez
    @ESquirez 3 года назад

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

  • @אנורסיאח
    @אנורסיאח 3 года назад

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

  • @andrevdw747
    @andrevdw747 4 года назад +1

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

  • @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!

  • @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!!

  • @sergiobost4891
    @sergiobost4891 4 года назад

    Just what I needed! Thanks!

  • @AlexCio
    @AlexCio 5 лет назад +2

    the animation looks smooth!

  • @kyoheo5326
    @kyoheo5326 4 года назад

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

  • @_armtic
    @_armtic 5 лет назад +3

    watching this from Japan!

  • @BalaaLyf
    @BalaaLyf 4 года назад

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

  • @rahuljamba5846
    @rahuljamba5846 3 года назад

    Excellent !!!

  • @GreenDevBabe
    @GreenDevBabe 5 лет назад

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

  • @jersey-dude
    @jersey-dude 5 лет назад

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

  • @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!

  • @briefinsight8758
    @briefinsight8758 4 года назад

    perfect! i liked it

  • @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.

  • @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?

  • @bolivarbryan
    @bolivarbryan 5 лет назад

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

  • @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?

  • @ضدالظلم-د4ح
    @ضدالظلم-د4ح 5 лет назад

    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.

  • @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.

  • @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."

  • @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?

  • @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?

  • @nurlankalybekov7336
    @nurlankalybekov7336 4 года назад

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

  • @SHIVAMGUPTA-pb7ru
    @SHIVAMGUPTA-pb7ru 4 года назад

    very clearly expalin

  • @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

  • @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: ruclips.net/video/-BZdQmHV4MQ/видео.html

  • @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)

  • @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 4 года назад +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.

  • @אנורסיאח
    @אנורסיאח 3 года назад

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