Storage Documentation

Structure Keychain​Storage

public struct KeychainStorage<Item: Storable>  

A struct defining a Storage caching Items safely inside the user's Keychain.

%91 KeychainStorage KeychainStorage Storage Storage KeychainStorage->Storage Sequence Sequence KeychainStorage->Sequence

Nested Types

KeychainStorage.Iterator

A struct defining a KeychainStorage iterator.

Conforms To

Sequence
Storage

Initializers

init(service:​group:​accessibility:​is​Synchronizable:​)

public init(
        service: String? = nil,
        group: String? = nil,
        accessibility: Accessibility = .whenUnlocked,
        isSynchronizable: Bool = false
    )  

Init.

Parameters

service String?

An optional String identifying the service name for the keychain instance.

group String?

An optional String identifying the service name for the keychain instance. Defaults to nil.

accessibility Accessibility

A valid Accessibility value. Defaults to .whenUnlocked.

is​Synchronizable Bool

A Bool representing whether the Secret should be shared through iCloud Keychain or not. Defaults to false.

init(service:​group:​accessibility:​authentication:​is​Synchronizable:​)

public init(
        service: String? = nil,
        group: String? = nil,
        accessibility: Accessibility = .whenUnlocked,
        authentication: AuthenticationPolicy = [],
        isSynchronizable: Bool = false
    )  

Init.

Parameters

service String?

An optional String identifying the service name for the keychain instance.

group String?

An optional String identifying the service name for the keychain instance. Defaults to nil.

accessibility Accessibility

A valid Accessibility value. Defaults to .whenUnlocked.

authentication Authentication​Policy

A valid Authentication value. Defaults to empty.

is​Synchronizable Bool

A Bool representing whether the Secret should be shared through iCloud Keychain or not. Defaults to false.

Methods

make​Iterator()

public func makeIterator() -> Iterator  

Compose the iterator.

Returns

Some IteratorProtocol.

insert(_:​)

@discardableResult
    public func insert(_ item: Item) throws -> (inserted: Bool, memberAfterInsert: Item)  

Insert a new item.

Parameters

item Item

Some Item.

Returns

A tuple indicating whether a previous value existed, and what this value was.

remove​Value(for​Key:​)

@discardableResult
    public func removeValue(forKey key: Item.ID) throws -> Item?  

Remove the associated item, if it exists.

Parameters

key Item.​ID

Some Item.ID.

Throws

Any Error.

Returns

The removed Item, if it exists.