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 Codable.

  • Initializes a new instance of KeychainStorage.

    This initializer configures a KeychainStorage instance with a specified account and security settings. It allows storing data securely in the keychain using the provided account identifier. T

    Declaration

    Swift

    public init(account: String, encryptor: Encryptor = NoEncryptor(), cacheable: Bool = false)

    Parameters

    account

    A String identifying the keychain account under which the data will be stored. This is used to differentiate between different sets of data within the keychain.

    encryptor

    An Encryptor instance for encrypting/decrypting the stored data. Default value is NoEncryptor()

    cacheable

    A Bool indicating whether the stored data should be cached. Defaults to false.