Learn Courses My Dashboard

Extension to learning app - question about retaining data

Hi there,

I’m new to app building and I’ve nearly completed the foundations course - just finishing off the city sights app. I’ve loved every second of it - really brilliant job.

I wanted to challenge myself with a slight extension to the learning app. I wanted to keep track of my last score in one of the quizzes so when I got to the ‘you got X out of Y’ screen it said something like ‘you got X out of Y and last time you got Z out of Y’.

What I was wondering is what would be the best way to store Z so that if the user closed the app it would still remember it? I’ve not done the database course but that sounds a bit extreme. For something like that would you suggest editing the json file slightly and writing Z to that json file? Or is there some other way that you would suggest retaining data like that?

This is just a general interest question - I’ve not attempted it yet, I just wanted a start point.

Thanks

Chris

Google for UserDefaults
https://developer.apple.com/documentation/foundation/userdefaults

Really easy, maybe it’s in the solution for the stock tracker app challenge? (I think it was one off the challenges there).

Brilliant, thank-you for your quick reply! That’s really useful - I shall go and consult the stock tracker app and learn a new skill! Thanks a lot.