forked from Read-Write/Submariner
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #203 from SubmarinerApp/picker-inspector
Inspector improvements
- Loading branch information
Showing
10 changed files
with
333 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// | ||
// Binding+Nil.swift | ||
// Submariner | ||
// | ||
// Created by Calvin Buckley on 2024-04-08. | ||
// | ||
// Copyright (c) 2024 Calvin Buckley | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
// | ||
|
||
import SwiftUI | ||
|
||
// https://alanquatermain.me/programming/swiftui/2019-11-15-CoreData-and-bindings/ | ||
extension Binding { | ||
init(_ source: Binding<Value?>, replacingNilWith nilValue: Value) where Value: Equatable { | ||
self.init( | ||
get: { source.wrappedValue ?? nilValue }, | ||
set: { newValue in | ||
if newValue == nilValue { | ||
source.wrappedValue = nil | ||
} | ||
else { | ||
source.wrappedValue = newValue | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.