Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 7: Get the Data: Storing and Ret... > Creating the High-Score Example

Creating the High-Score Example

So far, we've looked at persisting our application's data using a number of different techniques. Now let's explore how we can put this to use in our example application, the Lunar Lander game we started in Chapter 5. The one thing that jumps out in a game like ours is the need to persist our scores in a high score table, providing the players with another competitive dimension to the game. So, we'll apply our data persistence knowledge and look at creating an internal high-score structure that is available to be displayed on the start screen and persists between application instances.

Creating a Persistent High-Score Class

Our high-score feature is pretty straightforward. It will hold five entries, each with the name of the person who attained the high score and the score itself. We could carry on as in the previous example, and use standard Objective-C object types like NSString. This would have the advantage of being written to a plist file, but would incur complexity in how we interpret the file. Instead, we'll use a custom object that inherits from NSObject to store the actual high-score entries.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint