Updates the internal state of the game model to reflect the specified changes.
- iOS 9.0+
- macOS 10.11+
- Mac Catalyst 13.0+
- tvOS 9.0+
An instance of your custom class that implements the
GKGameprotocol, describing a move to be made in your game.
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 examine that information and perform the corresponding changes to your game model’s internal state. GameplayKit calls this method to speculate about possible future moves and their effects, using a copy of the active game board.
For example, a move class for a chess game would identify the piece to be moved and the space to which the piece will move. Your
apply(_:) method would update its model of the game board to reflect the new location of that piece and perform any actions that result from the move, such as capturing other pieces.
GameplayKit assumes that calling this method performs a move on behalf of the player identified by the