Class

GKPlayer

An object that provides information about a player on Game Center.

Overview

Every player account on Game Center is permanently assigned a unique player identifier string. Your game should use this string to store per-player information or to disambiguate between players. In most cases, Game Kit classes return player identifier strings to your game. For example, in a multiplayer match, the GKMatch object’s player​IDs property contains an array of the player identifiers for all the players connected to the match.

To load information about a set of players, your game calls the load​Players(for​Identifiers:​with​Completion​Handler:​) method, passing in an array of identifier strings. Your completion handler is called after the player data is downloaded from Game Center. For performance and resource reasons, player objects returned by the load​Players(for​Identifiers:​with​Completion​Handler:​) method do not include player photos. To load the photo associated with a player, call the player object’s load​Photo(for​Size:​with​Completion​Handler:​) method.

The concept of guest players is introduced in iOS 9. Guest players are treated exactly like authenticated players for Game Center multiplayer purposes. However, guest players cannot earn achievements, post to leaderboards, or participate in challenges. Create a guest player with the anonymous​Guest​Player(with​Identifier:​) method.

Symbols

Identifying the Player

var player​ID:​ String?

A string assigned by Game Center to uniquely identify a player.

Player Details

var alias:​ String?

A string chosen by the player to identify themselves to other players.

var display​Name:​ String?

A string to display for the player.

var is​Friend:​ Bool

A Boolean value that indicates whether this player is a friend of the local player.

Deprecated

Player Photos

GKPhoto​Size

The size of a photo loaded by Game Center.

Creating a Guest Player

class func anonymous​Guest​Player(with​Identifier:​ String)

Creates a new guest player with the designated identifier.

var guest​Identifier:​ String?

A developer created string used to identify a guest player.

Notifications

let GKPlayer​Did​Change​Notification​Name:​ String

Posted when a player object’s data changes.

Relationships

Inherits From