How to save data? Need help

How do you save data in a variable even when the program is closed?
I want to be able to save a high score in a game I’ve made but it deletes the data when the simulator goes back to the code, and it’s on the App Store now, and it doesn’t save data when it goes back to the main screen or when you close the app. How would I save this data?

Look in the reference for saveProjectData() and readProjectData()

If that’s not what you’re looking for then I must have really misunderstood

For a project specific data use saveLocalData(“name”,string)

For Global data (used across projects) use saveGlobalData(“name”,string)

@Briarfox, @JessicGriffin, for Highscores he’s going to want saveLocalData

I really only ever use global data and file IO…

Global data is fine for stuff like high scores, you just need an original name for it. In my projects I usually use “project name.variable name”, i.e. “Expansion+.level1”

Thanks @JakAttak , @Briarfox , and @SkyTheCoder . I’ll check the reference to see if i understand better.