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

24. GameKit > Accessing Leaderboards

Accessing Leaderboards

You can easily query the entire list of leaderboard categories. Many applications have just one leaderboard for top scores. Others have leaderboards for various categories, like most accurate shooter or greatest word length. The following method retrieves the categories (e.g., com.sadun.cookbook.topPoints) and titles (e.g., Top Points) for each available leaderboard:

- (void) peekAtLeaderboards
{
    [GKLeaderboard loadCategoriesWithCompletionHandler:
        ^(NSArray *categories, NSArray *titles, NSError *error)
     {
         if (error)
         {
             NSLog(@"Error retrieving leaderboard categories: %@",
                 error.localizedFailureReason);
             return;
         }

         for (int i = 0; i < categories.count; i++)
         {
             NSString *category = [categories objectAtIndex:i];
             NSString *title = [titles objectAtIndex:i];
             NSLog(@"%@ : %@", category, title);
         }
     }];
}


  

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