Attempts to transition the state machine from its current state to a state of the specified class.
- iOS 9.0+
- macOS 10.11+
- Mac Catalyst 13.0+
- tvOS 9.0+
The class of state into which to attempt a transition.
true if the transition was successful; otherwise
You build a state machine by creating a unique
GKState subclass for each distinct state possible for the machine. The
is method of each state object determines which other states a state machine is allowed to transition into from that state. Calling this method first tests whether a transition from the current state to the specified state is valid; if not, this method returns
If a transition is allowed, the state machine sends the
will message to its current state object. Then, the new state object replaces the value of the
current property. Finally, the state machine sends the
did message to the new current state object, and this method returns
A newly created state machine’s
current property is
nil—to choose and enter an initial state, use the
enter(_:) method. In this case, the
enter(_:) call always succeeds.