views:

34

answers:

2

I am extreamly new to programming. I am writing a simple game which gives you a score everytime you run the game. I am trying to figure out how to save the scores and recall them to a high score page. I am trying to figure out if saving to a dictionary is the best way, or using an array, or what. Plus, how does the dictionary handle an object that needs to be updated and changed, everytime the high score is beat?

A: 

well, the simplest way is just to store them in a text file. How this works is relatively simple in any programming language and most languages will have some documentation online that explains the functions for reading and writing from files. How to actually handle the values in memory (array, list, etc) will depend on the language you are using.

MaQleod
A: 

I'm new to Obj-C too, but from a pure programming point of view I'd agree with maqleod. You're problem is twofold: you need a data structure to hold the highscores in memory whilst your game is running. I think an NsMutableArray would serve you best, because it can sort itself for you (an NsDictionary is better when you want to lookup discrete values). On a higher level however, you need to save this data between sessions - data persistency. Thats where saving to a text file comes into play. If you look up / google "archiving objects" you'll find that it' really quite a trivial task in obj-c to save the contents of an object (eg. An array containing highscores) to a file - and of course initialize it again from file next time the game starts up.

Rich