Skip to content

Instantly share code, notes, and snippets.

@ykpoh
Created August 7, 2021 11:41
Show Gist options
  • Save ykpoh/b9c1229a1f938dda0973b620211dea9a to your computer and use it in GitHub Desktop.
Save ykpoh/b9c1229a1f938dda0973b620211dea9a to your computer and use it in GitHub Desktop.
import KeychainAccess
class KeychainHelper {
let service = "QKLSKFNAE1.com.example.yungkien.com.shared"
let accessGroup = "group.com.example.yungkien.com.shared"
func save(_ key: String, _ value: String) throws {
let keychain = Keychain(service: service, accessGroup: accessGroup)
try keychain.set(value, key: key.rawValue)
}
func load(key: String) throws -> String? {
let keychain = Keychain(service: service, accessGroup: accessGroup)
return try keychain.getString(key.rawValue)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment