SPONSORED Transform your career with the iOS Lead Essentials. This Black Friday, unlock over 40 hours of expert training, mentorship, and community support to secure your place among the best devs. Click for early access to this limited offer and a free crash course. Sponsor Hacking with Swift and reach the world's largest Swift community! |
|
Did you invent the approach of having a custom I suspect you should replace the init with an This article might be helpful: https://swiftbysundell.com/articles/the-lifecycle-and-semantics-of-a-swiftui-view/ |
|
@bobstern it wasn't in a tutorial, it was from a project I had worked on in the past. I remember being shared a couple articles on it but I can't seem to track them down to share the link. Mostly because it appears I can't find the right way to enter my question into google. But it had something to do memory management I believe and lifecycles. However, I did try using your suggestion, and I'm still unable to proceed. This is very strange |
|
@kenada_95, Try to check first if path is actually added where you have the problem. NavPath has property UPD: Also just thinking further... Maybe to try instantiate the model in current view and then pass it further as ready object. I suppose you press the button "CONTINUE" and your model instatiated at the same moment, right? And and the same time navigation happens, mmmm maybe there is not enought time to instantiate model to navigate forward.... In you debug project models are classes that contain just a string and an int, so it doesn't take time to instantiate them. In your real project who knows... |
|
@ygeras, I've found the count to be about what i expected it to be, its not nil by any means but this is the print out from it "NavigationPath(items: SwiftUI.NavigationPath.(unknown context at $10a317200).Representation.eager([SwiftUI.(unknown context at $10a316e78).ItemBox<SplashScreenExample.ContentViewViewModel>]), subsequentItems: [], iterationIndex: 0)" when i press "Continue" in ContentView. However I tried your method of instantiating the WelcomeScreens view model in content view before appending it I have found that i can't even reach the ContentView itself. It stays stuck on the loading animation in the bumper screen. To make this happen I have posted the code below and left in some of the bools I have in the view.
|
|
And what is the function of this modifier in ContentView? Without detailed view of the code no more ideas :(
|
|
@ygeras is a custom property to toggle popups. I've toyed with this before as well, removed the sheet manager as a environment property, etc. and its still the same bug. I wonder if this is something that needs to be filed with Apple.
|
|
Well if you sample project works without issues, means that Apple frameworks work as intended. Most probably there is something in your code that prevents navigating. You'd better deconstruct completely your code and by adding logic check where the issue starts. Or using debugger go into details what is going on behind the scenes. But that cryptic data from debugger is very often indecipherable for most of us )))) Have you tried to set up navigation without handling navPaths and passing data. But just simply using NavigationLinks and let SwiftUI take care of the rest? As I noticed, you do not really passing data around but instantiating datamodels and then pass that objects to your views. What if instead let the view instantiate model itself. Something simple as in the below code: (well, if it fits your logic of course)
|
|
@ygeras thank you for your help, i believe I found the problem to be not specific to how i'm navigating but is specific to the WelcomeScreenView. I've navigated from ContentView to the view "after" welcomescreen and functions as normal. So the methodology i'm using isn't wrong, it's something specific to this WelcomeScreenView and for whatever reason the binding to the Path within this view since removing the path still allows me to reach it. So I decided to post the whole screen and not leave out anything.
|
|
I have an Observable Model, where I use a
My model is @EnvironmentObject for all child views, the rest is easy :) |
SPONSORED Transform your career with the iOS Lead Essentials. This Black Friday, unlock over 40 hours of expert training, mentorship, and community support to secure your place among the best devs. Click for early access to this limited offer and a free crash course.
Sponsor Hacking with Swift and reach the world's largest Swift community!
This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.