Instance Method


Updates the internal state of the game model to reflect the specified changes.



func apply(_ gameModelUpdate: GKGameModelUpdate)



An instance of your custom class that implements the GKGameModelUpdate protocol, describing a move to be made in your game.


Your implementation of the GKGameModelUpdate 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 activePlayer property.

See Also

Modifying a Game Model

func unapplyGameModelUpdate(GKGameModelUpdate)

Updates the internal state of the game model to remove the effect of the specified changes.

func setGameModel(GKGameModel)

Sets the game model’s internal state to that of the specified game model.