diff options
| author | Jeff Halter <868228+jhalter@users.noreply.github.com> | 2024-06-10 15:19:11 -0700 |
|---|---|---|
| committer | Jeff Halter <868228+jhalter@users.noreply.github.com> | 2024-06-10 15:19:11 -0700 |
| commit | f8bb263ad12b87da4a7a249edd44932a9e7d1f17 (patch) | |
| tree | f74af8ce88789204c760f286957a2551c5f1bf04 /Hotline/Utility/FoundationExtensions.swift | |
| parent | bb292ec9ade3ed323108ff805b4a6c53115122ba (diff) | |
Add account management functionality
Diffstat (limited to 'Hotline/Utility/FoundationExtensions.swift')
| -rw-r--r-- | Hotline/Utility/FoundationExtensions.swift | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Hotline/Utility/FoundationExtensions.swift b/Hotline/Utility/FoundationExtensions.swift index 9cf2992..b5a2c34 100644 --- a/Hotline/Utility/FoundationExtensions.swift +++ b/Hotline/Utility/FoundationExtensions.swift @@ -594,3 +594,21 @@ extension FourCharCode { return String(bytes: bytes, encoding: .ascii) ?? "" } } + +extension Binding where Value: OptionSet, Value == Value.Element { + func bindedValue(_ options: Value) -> Bool { + return wrappedValue.contains(options) + } + + func bind(_ options: Value) -> Binding<Bool> { + return .init { () -> Bool in + self.wrappedValue.contains(options) + } set: { newValue in + if newValue { + self.wrappedValue.insert(options) + } else { + self.wrappedValue.remove(options) + } + } + } +} |