Testing for Game Center

Before any Game Center–specific code can be called, we need to perform a test to verify that the user has a version of iOS that supports Game Center. The first thing we need to do to perform this check is to create our new GameCenterManager class. We will use this class throughout the remainder of this book to keep our Game Center functionality in one easy-to-access class. This class will house all of our Game Center–specific code and callbacks, and can be easily shared across all of your apps.

First, create a new file in Xcode. You will want to select the Objective-C Subclass from the available templates. Make sure that you also select NSObject under the “Subclass of” pull-down menu. Name the new class GameCenterManager, ...

Get Beginning iOS Game Center and Game Kit: For iPhone, iPad, and iPod touch now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.