Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Saving values of ints SWIFT

When I make my app, I have a highscore value. The problem is that when the app closes and reopens, the highscore goes back to zero. Is there any way to save the value so that the high score can be saved to device storage? Thanks in advance!

2 Answers

Hey,

I found a stack overflow answer that should help you out with your problem

http://stackoverflow.com/questions/25985450/saving-highscores-with-nsuserdefaults

Let me know if it does not work :),

Ozzie

Thanks so much Ozzie. As a begginer with iOS I had already looked at that...it's so confusing it blew my mind. Oh how I wish a course on master-detail or game applications for swift would come out!

I completely agree with you, Treehouse should cover more about the game development in swift and master-detail courses here on Treehouse. The code for saving an int value can be a bit confusing, What I like to do is to try and play around with code to get a better grip on it. You can try renaming the variable to something more like you would call them, that also help.

If you are trouble having trouble implementing the code for the highest score functions, feel free to email the project to me and I would be happy to help you out,

Ozzie ozzie@kirkbyo.net