Structure
UserDefaultsStorage
public struct UserDefaultsStorage<Item: Storable>
A struct
defining a Storage
caching Item
s in UserDefaults
.
Relationships
Nested Types
UserDefaultsStorage.Iterator
A
struct
defining aUserDefaultsStorage
iterator.
Conforms To
Sequence
Storage
Initializers
init(userDefaults:)
public init(userDefaults: UserDefaults = .standard)
Init.
Parameters
Name | Type | Description |
---|---|---|
userDefaults | UserDefaults |
Some |
Methods
makeIterator()
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
Name | Type | Description |
---|---|---|
item | Item |
Some |
Returns
A tuple indicating whether a previous value existed, and what this value was.
removeValue(forKey:)
@discardableResult
public func removeValue(forKey key: Item.ID) throws -> Item?
Remove the associated item, if it exists.
Parameters
Name | Type | Description |
---|---|---|
key | Item.ID |
Some |
Throws
Any Error
.
Returns
The removed Item
, if it exists.