Chapter 9. Saving scores

Now that you are able to reach the end of the game, it’s time to save your scores on the device and brag about it by publishing the scores to GameCenter. In this chapter we cover saving score using the following:

  1. NSUserDefaults from UIKit
  2. Leaderboards from GameKit

NSUserDefaults is an old framework from back when NextStep was around, which is why the class is prefixed with NS. Even though it is old, it is a quick way to save small chunks of data.

GameCenter was introduced in iOS5 and offers a quick way to saves scores online on their servers so that the scores can be viewed through the Game Center application. Besides a leaderboard, Game Center can be used for turn based games and to record achievements in the game ...

Get Learning Swift: Building an iOS Game now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.