---
title: "init(states:)"
framework: gameplaykit
role: symbol
role_heading: Initializer
path: "gameplaykit/gkstatemachine/init(states:)"
---

# init(states:)

Initializes a state machine with the specified states.

## Declaration

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

## Parameters

- `states`: An array of state objects. Each object in the array must be of a unique subclass of doc://com.apple.gameplaykit/documentation/GameplayKit/GKState.

## Return Value

Return Value A new state machine.

## Discussion

Discussion The newly created state machine’s currentState property is nil. To choose and enter an initial state, use the enter(_:) method. For more information, see GameplayKit Programming Guide.
