<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/Binding/init(get:set:)-6g3d5",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI7BindingV3get3setACyxGxyc_yx_AA11TransactionVtctcfc"
  },
  "title" : "init(get:set:)"
}
-->

# init(get:set:)

Creates a binding with a closure that reads from the binding value, and
a closure that applies a transaction when writing to the binding value.

```
@preconcurrency init(get: @escaping @isolated(any) @Sendable () -> Value, set: @escaping @isolated(any) @Sendable (Value, Transaction) -> Void)
```

## Parameters

`get`

A closure to retrieve the binding value. The closure has no
parameters, and returns a value.

`set`

A closure to set the binding value. The closure has the
following parameters:

- newValue: The new value of the binding value.
- transaction: The transaction to apply when setting a new value.

## Discussion

A binding conforms to Sendable only if its wrapped value type also
conforms to Sendable. It is always safe to pass a sendable binding
between different concurrency domains. However, reading from or writing
to a binding’s wrapped value from a different concurrency domain may or
may not be safe, depending on how the binding was created. SwiftUI will
issue a warning at runtime if it detects a binding being used in a way
that may compromise data safety.

For a “computed” binding created using get and set closure parameters,
the safety of accessing its wrapped value from a different concurrency
domain depends on whether those closure arguments are isolated to
a specific actor. For example, a computed binding with closure arguments
that are known (or inferred) to be isolated to the main actor must only
ever access its wrapped value on the main actor as well, even if the
binding is also 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)