Class

GKChallenge

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

Declaration

@interface GKChallenge : NSObject

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 loadReceivedChallengesWithCompletionHandler: 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.

Topics

Retrieving the List of Challenges to the Local Player

+ loadReceivedChallengesWithCompletionHandler:

Loads the list of outstanding challenges.

Examining Details about a Challenge

issuingPlayer

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

receivingPlayer

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

message

A text message that describes the challenge.

state

The current state of the challenge.

GKChallengeState

Possible states that a challenge can live in.

issueDate

The date the challenge was issued.

completionDate

The date the challenge was completed.

Declining a Challenge

- 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 Properties

issuingPlayerID

The player who issued the challenge.

Deprecated
receivingPlayerID

The player who received the challenge.

Deprecated

Relationships

Inherits From

See Also

Challenges

GKScoreChallenge

An object representing a challenge based on a score in a leaderboard.

GKAchievementChallenge

A challenge sent to another player urging them to complete a specific achievement.

GKChallengeListener

An object that responds to challenge events.