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.
Very nice, short & sweet, right to the point - no fluff. Thanks.
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!!
Thanks for keeping the subject up to date.
thanks for covering for the ObservableObject (because of the deprecated BindableObject).
This is the most straight to the point and relevant video for me! Thanks a million, ur content is awesome
What an amazing explanation! Thank you so much, i have been having problems understanding this!!!
Fantastic brain
The way you explained this was spot on 👏🏿👏🏿👏🏿
Thanks man, this video has been very helpful for me with my project that I'm working on. You are very well informed!
Great tutorial Brian! One of the few that explained also the WHY :-)
Thanks a lot, the most instructive video I've watched 😊
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!
Superb tutorial Brian, as always detailed video, described data transfer between views nicely. I always look forward to your videos and tutorials...Thanks!!
Just what I needed! Thanks!
the animation looks smooth!
You are so cool! thank you very much please more videos like this !!!
watching this from Japan!
Fine. Now go kill some whales...
Please upload one more video for this pass data.. Multiple labels and multiple textfields.. Data transfer and save it
Excellent !!!
Hi Brian. Please make small video about new BackgroundTasks. Because old doesn't work well anymore in Xcode 11.
really quality content and very well explained. subbed on patreon. Thx for the content
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!
perfect! i liked it
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?
That is just the nature of @EnvironmentObject It's like a "singleton", but not really, there's more to it.
Great Content man, love it , very knowledgable.
Great! suppose that the SecondView has another struct as ThirdView in the same class and how can we dismiss the sheet from ThirdView?
Greetings from Colombia Brian. Thanks for sharing this content, Great work done here :-)
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?
You are amazing 😉
It’s so Fantastic 😳👍
Thank you so much ☺️
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.
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.
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.
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
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
@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."
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?
SecondView seems to be asking for variable initializing down in the preview_ ???
I just delete those bits and run the simulator, lazy i know but i dont really get it, you fix it?
It would be much more interactive if you keep typing during video, instead of Copy/Paste-ing us ready code
very clearly expalin
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
How does this interact with core data?
Check out his other video about SwiftUI with Core Data: ruclips.net/video/-BZdQmHV4MQ/видео.html
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())
try just "let context = (UIApplication..........
im guessing you error might be a invalid redeclaration error?
let context = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext
let contentView = ContentView().environment(\.managedObjectContext, context)
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.
Such a long video to explain a simple concept ,!!!!!
Bad didaktik, zu viele themen vorher geshrieben....zb model
It’s too long video and clumsy for beginners to get your idea in mind.
Thanks man, this video has been very helpful for me with my project that I'm working on. You are very well informed!