How progress is saved?

Hi community,

I want to build an app with simple lessons.
Ex: You have a list of lessons but only one is available. Once you finish the first one and tap the button at the end of it, your second lesson is unlocked and you can access it.

Can you guys help me with this?
Maybe point me to some tutorial that explains that?

My challenge is that I can’t really understand how the progress is saved. If someone closes the app, how do I make sure the list with available/unavailable lessons is still there in the same form as the user left it?

Thank you in advance!

Stefan

Hi Stefan welcome to the community!

Like anything with programming, you can do this many different ways :slight_smile:

First I would say, try using UserDefaults.
This is a value that you can save and access no matter if the user closes the app.

I would suggest saving the value of what level the user is at. So then you just increase it every time the user unlocks a new level

https://www.hackingwithswift.com/read/12/2/reading-and-writing-basics-userdefaults

Or you could have a JSON file on the app and save values in a key-value pair, depending how you lay out the data

1 Like

Thanks a lot! I will look into it :grin: