|
In the day 35 challenge I would like to understand how it works to switch between the views (GameView,SettingsView) using closures.
I tried a lot but without success and it would be great if someone can give me a hint.
I tried to understand the hint given by @FlyOstrich at SOLVED: Looking for clue for Day 35 challenge (Multiply!) but without success. Any ideas are welcome :-) Regards, Ralf |
|
First need a
Then in the ContentView you can have, which will show either view depend on
now need to be able to change between so add a method
but what needed is say number of questions to answer as a
need to be able set
and now can pass the
so now we need to be able to call the
This is very rough as just want to show how to pass the method from one view to another (took me age to get this). It might give you a starting point for the challange.
|
|
Hello @NigelGee, Thank you! You definitely made my day :-) Greetings Ralf |
|
I used some of these ideas in my version of the Day 35 challenge. I have it working well, except for when the game is over, I dont know how to get it to go back to SettingsView(). Going from SettingsView() to GameView() works and the game play works, I just cant figure out how to go backwards? setting gameStarted = false does nothing, and I tried a NavigationLink but I am not sure I did that correctly as that didnt work either... |
|
|
|
SPONSORED Ready to dive into the world of Swift? try! Swift Tokyo is the premier iOS developer conference will be happened in April 9th-11th, where you can learn from industry experts, connect with fellow developers, and explore the latest in Swift and iOS development. Don’t miss out on this opportunity to level up your skills and be part of the Swift community!
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.