0Pricing
Swift Academy · Lesson

Projected Values with $binding

Exposing a projectedValue to provide additional functionality via $prefix.

Welcome

Projected values (accessed via `$`) give property wrappers a secondary interface — used by SwiftUI's `@State` and `@Published` to expose `Binding` and `Publisher`.

Adding projectedValue

```swift @propertyWrapper struct Toggle { var wrappedValue: Bool = false var projectedValue: String { wrappedValue ? "ON" : "OFF" } } struct Model { @Toggle var active } var m = Model() print(m.$active) // "OFF" — projected value accessed with $ ```

All lessons in this course

  1. Creating a Custom Property Wrapper
  2. Projected Values with $binding
  3. @Published and Observation in Combine
  4. Composing Multiple Property Wrappers
← Back to Swift Academy