Skip to content

Instantly share code, notes, and snippets.

@nsoojin
Created October 26, 2019 08:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nsoojin/ad5f909272358aa518d38e3786f86c2e to your computer and use it in GitHub Desktop.
Save nsoojin/ad5f909272358aa518d38e3786f86c2e to your computer and use it in GitHub Desktop.
SharedKeychain Property Wrapper
@propertyWrapper
struct SharedKeychain {
let key: String
var wrappedValue: String? {
get {
return Global.sharedKeychain[string: key]
}
set {
if let value = newValue {
try? Global.sharedKeychain.set(value, key: key)
} else {
try? Global.sharedKeychain.remove(key)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment