Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to call a function on original view when modal view is dismissed

I have a SwiftUI puzzle game. I store played puzzles and show in the history view. History view is displayed as a sheet when a button is tapped. In the history view, I want to have a button ("Replay puzzle") which should 1) dismiss the history view, and 2) run a function in the main view so that a game from history view can be replayed.

Seems simple but I could not figure out how to call a function in the main view to update the current game. Any pointers would be appreciated.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Use onDismiss parameter of .sheet, like in https://stackoverflow.com/a/63673342/12299030

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading