<!--
{
  "availability" : [
    "iOS: 9.0.0 -",
    "iPadOS: 9.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.11.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "GameplayKit",
  "identifier" : "/documentation/GameplayKit/GKStateMachine/init(states:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "GameplayKit"
    ],
    "preciseIdentifier" : "c:objc(cs)GKStateMachine(im)initWithStates:"
  },
  "title" : "init(states:)"
}
-->

# init(states:)

Initializes a state machine with the specified states.

```
init(states: [GKState])
```

## Parameters

`states`

An array of state objects. Each object in the array must be of a unique subclass of [`GKState`](/documentation/GameplayKit/GKState).

## Return Value

A new state machine.

## Discussion

The newly created state machine’s [`currentState`](/documentation/GameplayKit/GKStateMachine/currentState) property is `nil`. To choose and enter an initial state, use the [`enter(_:)`](/documentation/GameplayKit/GKStateMachine/enter(_:)) method.

For more information, see [GameplayKit Programming Guide](https://developer.apple.com/library/archive/documentation/General/Conceptual/GameplayKit_Guide/index.html#//apple_ref/doc/uid/TP40015172).

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)