]>
Commit | Line | Data |
---|---|---|
1b85f723 RBR |
1 | import SwiftUI |
2 | ||
3 | extension Binding { | |
4 | init(_ source: Binding<Value?>, _ defaultValue: Value) { | |
5 | // Ensure a non-nil value in `source`. | |
6 | if source.wrappedValue == nil { | |
7 | source.wrappedValue = defaultValue | |
8 | } | |
9 | // Unsafe unwrap because *we* know it's non-nil now. | |
10 | self.init(source)! | |
11 | } | |
12 | } |