UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

how to restore the app state?

Forums > SwiftUI

I have a tutorial-like app which has integrated quizzes after every few set of tutorials.

I would like to add two functionalities to this app:

  1. Ability to restore the state of the app, i.e. bring the user back to the same location which they left after, say, restarting the device.
  2. How do I ensure that the progress of the user in the quizzes are stored and doesn't get deleted.

Any pointers will be very helpful. Thanks.

   

You have to add persistance to your app. What does this mean? You have to somehow store progress of your game on the device physically and not just in RAM. You can do this f.e. with SwiftData or CoreData. So when your app restarts the saved progress is restored and your user can continue where he left off.

As we don't know how your app works it's difficult to give more detailed advice.

   

BUILD THE ULTIMATE PORTFOLIO APP Most Swift tutorials help you solve one specific problem, but in my Ultimate Portfolio App series I show you how to get all the best practices into a single app: architecture, testing, performance, accessibility, localization, project organization, and so much more, all while building a SwiftUI app that works on iOS, macOS and watchOS.

Get it on Hacking with Swift+

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.