Storage Documentation

Structure User​Defaults​Storage

public struct UserDefaultsStorage<Item: Storable>  

A struct defining a Storage caching Items in UserDefaults.

%11 UserDefaultsStorage UserDefaultsStorage Sequence Sequence UserDefaultsStorage->Sequence Storage Storage UserDefaultsStorage->Storage

Nested Types

UserDefaultsStorage.Iterator

A struct defining a UserDefaultsStorage iterator.

Conforms To

Sequence
Storage

Initializers

init(user​Defaults:​)

public init(userDefaults: UserDefaults = .standard)  

Init.

Parameters

user​Defaults User​Defaults

Some UserDefaults. Defaults to .standard.

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.