KeychainStorage
public class KeychainStorage<T> : StorageDelegate<T>, @unchecked Sendable where T : Decodable, T : Encodable, T : Sendable
KeychainStorage is a generic class that conforms to the StorageDelegate protocol, providing a secure storage solution by leveraging the keychain.
It is designed to store, retrieve, and manage objects of type T, where T must conform to the Codable protocol. This requirement ensures that the objects can be easily encoded and decoded for secure storage in the keychain.
Parameters
T
|
The type of the objects to be stored in the keychain. Must conform to |
-
Initializes a new instance of
KeychainStorage.This initializer configures a
KeychainStorageinstance with a specified account and security settings. It allows storing data securely in the keychain using the provided account identifier. TDeclaration
Swift
public init(account: String, encryptor: Encryptor = NoEncryptor(), cacheable: Bool = false)Parameters
accountA
Stringidentifying the keychain account under which the data will be stored. This is used to differentiate between different sets of data within the keychain.encryptorAn
Encryptorinstance for encrypting/decrypting the stored data. Default value isNoEncryptor()cacheableA
Boolindicating whether the stored data should be cached. Defaults tofalse.