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
- Creating a Custom Property Wrapper
- Projected Values with $binding
- @Published and Observation in Combine
- Composing Multiple Property Wrappers