<!--
{
  "availability" : [
    "Reality Composer Pro: -",
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: 27.0.0 -",
    "macOS: 27.0.0 -",
    "tvOS: 27.0.0 -",
    "visionOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "ComputeGraph",
  "identifier" : "/documentation/ComputeGraph/ComputeNodeGraph/StateDefinition",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Compute Graph",
      "ComputeGraph"
    ],
    "preciseIdentifier" : "s:12ComputeGraph0a4NodeB0V15StateDefinitionV"
  },
  "title" : "ComputeNodeGraph.StateDefinition"
}
-->

# ComputeNodeGraph.StateDefinition

A declaration of a named state value and where it lives in the simulation.

```
struct StateDefinition
```

## Overview

State definitions are used by `ComputeNodeGraph/Node/Kind/loadState(definition:)`
and `ComputeNodeGraph/Node/Kind/storeState(definition:)` nodes to read and
write values at a particular scope.

## Topics

### Structures

[`struct Options`](/documentation/ComputeGraph/ComputeNodeGraph/StateDefinition/Options-swift.struct)

### Initializers

[`init(scope: ComputeNodeGraph.Scope, options: ComputeNodeGraph.StateDefinition.Options, type: ComputeNodeGraph.StateType)`](/documentation/ComputeGraph/ComputeNodeGraph/StateDefinition/init(scope:options:type:))

### Instance Properties

[`var options: ComputeNodeGraph.StateDefinition.Options`](/documentation/ComputeGraph/ComputeNodeGraph/StateDefinition/options-swift.property)

Whether this state is read, written, or both. See [`ComputeNodeGraph.StateDefinition.Options`](/documentation/ComputeGraph/ComputeNodeGraph/StateDefinition/Options-swift.struct).

[`var scope: ComputeNodeGraph.Scope`](/documentation/ComputeGraph/ComputeNodeGraph/StateDefinition/scope)

The scope that owns this state. For example, `ComputeNodeGraph/Scope/element`
stores a value per particle, while `ComputeNodeGraph/Scope/emitter` stores
a single value used by the emission stage.

[`var type: ComputeNodeGraph.StateType`](/documentation/ComputeGraph/ComputeNodeGraph/StateDefinition/type)

The data type of the stored value.

## Relationships

### Conforms To

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Equatable`](/documentation/Swift/Equatable)

[`Sendable`](/documentation/Swift/Sendable)

---

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)