|
I tried to adapt the navigation solution from the post "SOLVED: NavigationLink back button edit?" on May 23' such that i can pass data to the respective screens. I am know facing the problems that this works for one Screen, but not for the other, even though i am essentially doing the same thing. In the following, I want to go from the actual Game screen to an End screen. For simplicity and testing, I used a button to do so:
Here is the code of the navigate function:
When Pressing the Button, it only passing the default value (Player) since 'test' is apparently nil, which i don't understand since pass it as parameter directly. Despite doing the same when navigating to the Games Screen 'GameView', it does not complain because of any nil values or whatsoever. This is the rough structure of the destination.
Thanks in advance. |
|
What does your |
|
Consider using a
|
|
@roosterboy this is how the struct looks like:
I ve also just found something really interesing...
When pressing the button the View somehow still changes even though the navigate function is never being called. But this somewhat explains why it complains because of Nil value in that case. |
|
I think @Obelix is on to the cause, actually. Your
you aren't passing anything for Yet, you are force unwrapping You need to handle the event that |
|
I do not think
Could it be possible that the issue is linked to my previous post? Becasue I do not understand how the navigation is even possible when leaving out the
|
|
Well I now got my programm to behave like I want it to, but by using another approach for Navigation. I guess we'll never know what the true problem was xD. But still thanks for helping :D |
SPONSORED Superwall lets you build & test paywalls without shipping updates. Run experiments, offer sales, segment users, update locked features and more at the click of button. Best part? It's FREE for up to 250 conversions / mo and the Superwall team builds out 100% custom paywalls – free of charge.
Sponsor Hacking with Swift and reach the world's largest Swift community!
You need to create an account or log in to reply.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.