From f8bb263ad12b87da4a7a249edd44932a9e7d1f17 Mon Sep 17 00:00:00 2001 From: Jeff Halter <868228+jhalter@users.noreply.github.com> Date: Mon, 10 Jun 2024 15:19:11 -0700 Subject: Add account management functionality --- Hotline/Utility/FoundationExtensions.swift | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'Hotline/Utility') 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 { + return .init { () -> Bool in + self.wrappedValue.contains(options) + } set: { newValue in + if newValue { + self.wrappedValue.insert(options) + } else { + self.wrappedValue.remove(options) + } + } + } +} -- cgit