Returns the set of moves available to the specified player.
- iOS 9.0+
- macOS 10.11+
- tvOS 9.0+
An instance of your game’s player class (a custom class implementing the
GKGameprotocol) representing the player whose moves are to be evaluated.
An array of instances of your game’s move class (a custom class implementing the
GKGame protocol), each representing a possible move for the specified player.
Your implementation of the
GKGame protocol, or move class, should add properties or methods that describe a move in terms of your game. In this method, you create one instance of your move class for each move currently allowed to the specified player, filling in each instance’s custom properties with the information that describes that move. GameplayKit calls this method to speculate about possible future moves and their effects, using a copy of the active game board.
For example, in a Tic-Tac-Toe game, the move class would identify which of the nine spaces on the board to place a mark in. Your
game method would create an instance of the move class for each space not already marked. Your implementation should also take into account whether any moves are possible at all—if the game has already been won or has resulted in a draw, this method should return
This method should return
nil if the specified player is not valid or if no moves are available to that player.