Created
February 21, 2022 07:11
-
-
Save ihamadfuad/045e03cb79bc996d3b50a3a4fbf46607 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var wrappedValue: Value? { | |
get { value } | |
nonmutating set { | |
value = newValue | |
do { | |
let encoded = try JSONEncoder().encode(value) | |
try Keychain().set(encoded, key: key) | |
} catch let error { | |
try? Keychain().remove(key) | |
} | |
} | |
} | |
var projectedValue: Binding<Value?> { | |
Binding(get: { wrappedValue }, set: { wrappedValue = $0 }) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment