I want to make a simple highscore system for my game. No posting online, just storing your best scores on the device, maybe being able to share them on Twitter or something like that.
My table is like this:
CREATE TABLE highscores ( name VARCHAR(10), score INT )
and then I want to find an easy way to retrieve the name, score and order it by score descending, returning the top 5.
SELECT name, score FROM highscores ORDER BY score DESC LIMIT 0, 5
I tried to do this, following this SQLite tutorial: http://dblog.com.au/iphone-development-tutorials/iphone-sdk-tutorial-reading-data-from-a-sqlite-database/
I created the database, set it up, tried to make my own wrapper, but I got the following problems:
- It worked loading the score, but loading the name, which I tried to convert to a NSString* like they do in the tutorial, wouldn't work, it just returned 0 even though I had set the name to "Johannes"
- If I navigated away from the scores page, and then back to the menu, and clicked on the scores page again the app crashed.
Any ideas? I'm really stressed I can't find ANYTHING online about this. :[