Sets the game model’s internal state to that of the specified game model.
- iOS 9.0+
- macOS 10.11+
- Mac Catalyst 13.0+Beta
- tvOS 9.0+
The game model instance from which to copy state.
Your implementation of this method should efficiently copy the internal state of the specified object into the current game model.
To examine the results of possible future moves, GameplayKit uses several instances of your game model class and calls the
set method many times. For example, in a game where seven possible moves are available on each turn, looking only a few turns ahead requires examining hundreds of thousands of board states. (Rather than continually create new instances of your game state class, GameplayKit reuses existing instances by cloning the state of one into another—this optimization improves memory efficiency.)
GKGame protocol extends the
NSCopying protocol. Because the
set method does the critical work of copying the internal state of your game model, you can use this method to implement the requirements of the the