Class

GKChallenge

An object representing a challenge issued by the local player to another player.

Overview

Players use the Game Center app to issue and view challenges. However, your game can also customize its challenge behaviors in a number of ways:

  • You can load the list of challenges issued to the local player by calling the loadReceivedChallenges(completionHandler:) class method. For example, you might do this to display the challenges in your game’s user interface.

  • Your app can issue challenges using a GKScore or GKAchievement object. Your game should only issue challenges when the local player initiates the action in your user interface.

Subclassing Notes

You never subclass the GKChallenge class directly. However, subclasses of GKChallenge represent specific kinds of challenges. Two challenge types exist:

  • A GKScoreChallenge is a challenge to beat a score the local player earned in a leaderboard.

  • A GKAchievementChallenge is a challenge to complete an achievement that the local player has already completed.

Symbols

Retrieving the List of Challenges to the Local Player

Examining Details about a Challenge

var issueDate: Date

The date the challenge was issued.

var issuingPlayer: GKPlayer?

The GKPlayer object associated with the player who issued the challenge.

var receivingPlayer: GKPlayer?

The GKPlayer object associated with the player who received the challenge.

var message: String?

A text message that describes the challenge.

var state: GKChallengeState

The current state of the challenge.

var completionDate: Date?

The date the challenge was completed.

GKChallengeState

Possible states that a challenge can live in.

Declining a Challenge

func decline()

Declines a challenge.

Constants

GKChallengeComposeCompletionBlock

Completion block that determines if a challenge has been issued and if so, who it is sent to.

Deprecated Methods

var issuingPlayerID: String?

The player who issued the challenge.

Deprecated
var receivingPlayerID: String?

The player who received the challenge.

Deprecated

Relationships

Inherits From