Persisted
@propertyWrapper
public struct Persisted<Value>
A property wrapper that wraps a Persister
.
-
The value that is persisted by the
Persister
.Declaration
Swift
public var wrappedValue: Value { get nonmutating set }
-
Create a new instance that stores the value against the
key
usingstorage
, defaulting todefaultValue
.Declaration
Parameters
key
The key to store the value against
storage
The storage to use to persist and retrieve the value.
cacheValue
When
true
the latest value will be cached in memory to improve performance when retrieving values, at the cost of increased memory usage.defaultValue
The value to use when a value has not yet been stored, or an error occurs.
defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
. -
Create a new instance that stores the value against the
key
usingstorage
, defaulting towrappedValue
.Declaration
Parameters
wrappedValue
The value to use when a value has not yet been stored, or an error occurs.
key
The key to store the value against
storage
The storage to use to persist and retrieve the value.
cacheValue
When
true
the latest value will be cached in memory to improve performance when retrieving values, at the cost of increased memory usage.defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
. -
Create a new instance that stores the value against the
key
usingstorage
, defaulting todefaultValue
.Declaration
Swift
public init<Storage: Persist.Storage, WrappedValue>( key: Storage.Key, storedBy storage: Storage, cacheValue: Bool = false, defaultValue: @autoclosure @escaping () -> Value = nil, defaultValuePersistBehaviour: DefaultValuePersistOption = [] ) where Storage.Value == WrappedValue, Value == Optional<WrappedValue>
Parameters
key
The key to store the value against
storage
The storage to use to persist and retrieve the value.
cacheValue
When
true
the latest value will be cached in memory to improve performance when retrieving values, at the cost of increased memory usage.defaultValue
The value to use when a value has not yet been stored, or an error occurs. Defaults to
nil
.defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
. -
Create a new instance that stores the value against the
key
usingstorage
, defaulting towrappedValue
.Declaration
Parameters
wrappedValue
The value to use when a value has not yet been stored, or an error occurs.
key
The key to store the value against
storage
The storage to use to persist and retrieve the value.
cacheValue
When
true
the latest value will be cached in memory to improve performance when retrieving values, at the cost of increased memory usage.defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
.
-
Create a new instance that stores the value against the
key
usingstorage
, defaulting todefaultValue
.Declaration
Parameters
key
The key to store the value against
storage
The storage to use to persist and retrieve the value.
cacheValue
When
true
the latest value will be cached in memory to improve performance when retrieving values, at the cost of increased memory usage.defaultValue
The value to use when a value has not yet been stored, or an error occurs.
defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
. -
Create a new instance that stores the value against the
key
usingstorage
, defaulting towrappedValue
.Declaration
Parameters
wrappedValue
The value to use when a value has not yet been stored, or an error occurs.
key
The key to store the value against
storage
The storage to use to persist and retrieve the value.
cacheValue
When
true
the latest value will be cached in memory to improve performance when retrieving values, at the cost of increased memory usage.defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
. -
Create a new instance that stores the value against the
key
usingstorage
, defaulting todefaultValue
.Declaration
Swift
public init<Storage: Persist.Storage, WrappedValue>( key: Storage.Key, storedBy storage: Storage, cacheValue: Bool = false, defaultValue: @autoclosure @escaping () -> Value = nil, defaultValuePersistBehaviour: DefaultValuePersistOption = [] ) where Storage.Value == Any, Value == Optional<WrappedValue>
Parameters
key
The key to store the value against
storage
The storage to use to persist and retrieve the value.
cacheValue
When
true
the latest value will be cached in memory to improve performance when retrieving values, at the cost of increased memory usage.defaultValue
The value to use when a value has not yet been stored, or an error occurs. Defaults to
nil
.defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
. -
Create a new instance that stores the value against the
key
usingstorage
, defaulting towrappedValue
.Declaration
Parameters
wrappedValue
The value to use when a value has not yet been stored, or an error occurs.
key
The key to store the value against
storage
The storage to use to persist and retrieve the value.
cacheValue
When
true
the latest value will be cached in memory to improve performance when retrieving values, at the cost of increased memory usage.defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
.
-
Create a new instance that stores the value against the
key
usingstorage
, defaulting todefaultValue
. Values stored will be processed by the provided transformer before being persisted and after being retrieved from the storage.Declaration
Swift
public init<Storage: Persist.Storage, Transformer: Persist.Transformer>( key: Storage.Key, storedBy storage: Storage, transformer: Transformer, cacheValue: Bool = false, defaultValue: @autoclosure @escaping () -> Value, defaultValuePersistBehaviour: DefaultValuePersistOption = [] ) where Storage.Value == Any, Transformer.Input == Value
Parameters
key
The key to store the value against
storage
The storage to use to persist and retrieve the value.
transformer
A transformer to transform the value before being persisted and after being retrieved from the storage
cacheValue
When
true
the latest value will be cached in memory to improve performance when retrieving values, at the cost of increased memory usage.defaultValue
The value to use when a value has not yet been stored, or an error occurs.
defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
. -
Create a new instance that stores the value against the
key
usingstorage
, defaulting todefaultValue
. Values stored will be processed by the provided transformer before being persisted and after being retrieved from the storage.Declaration
Swift
public init<Storage: Persist.Storage, Transformer: Persist.Transformer>( wrappedValue: Value, key: Storage.Key, storedBy storage: Storage, transformer: Transformer, cacheValue: Bool = false, defaultValuePersistBehaviour: DefaultValuePersistOption = [] ) where Storage.Value == Any, Transformer.Input == Value
Parameters
wrappedValue
The value to use when a value has not yet been stored, or an error occurs.
key
The key to store the value against
storage
The storage to use to persist and retrieve the value.
cacheValue
When
true
the latest value will be cached in memory to improve performance when retrieving values, at the cost of increased memory usage.transformer
A transformer to transform the value before being persisted and after being retrieved from the storage
defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
. -
Create a new instance that stores the value against the
key
usingstorage
, defaulting todefaultValue
. Values stored will be processed by the provided transformer before being persisted and after being retrieved from the storage.Declaration
Swift
public init<Storage: Persist.Storage, Transformer: Persist.Transformer, WrappedValue>( key: Storage.Key, storedBy storage: Storage, transformer: Transformer, cacheValue: Bool = false, defaultValue: @autoclosure @escaping () -> Value = nil, defaultValuePersistBehaviour: DefaultValuePersistOption = [] ) where Storage.Value == Any, Transformer.Input == WrappedValue, Value == WrappedValue?
Parameters
key
The key to store the value against
storage
The storage to use to persist and retrieve the value.
transformer
A transformer to transform the value before being persisted and after being retrieved from the storage
cacheValue
When
true
the latest value will be cached in memory to improve performance when retrieving values, at the cost of increased memory usage.defaultValue
The value to use when a value has not yet been stored, or an error occurs. Defaults to
nil
.defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
. -
Create a new instance that stores the value against the
key
usingstorage
, defaulting towrappedValue
. Values stored will be processed by the provided transformer before being persisted and after being retrieved from the storage.Declaration
Swift
public init<Storage: Persist.Storage, Transformer: Persist.Transformer, WrappedValue>( wrappedValue: Value, key: Storage.Key, storedBy storage: Storage, transformer: Transformer, cacheValue: Bool = false, defaultValuePersistBehaviour: DefaultValuePersistOption = [] ) where Storage.Value == Any, Transformer.Input == WrappedValue, Value == WrappedValue?
Parameters
wrappedValue
The value to use when a value has not yet been stored, or an error occurs.
key
The key to store the value against.
storage
The storage to use to persist and retrieve the value.
transformer
A transformer to transform the value before being persisted and after being retrieved from the storage.
cacheValue
When
true
the latest value will be cached in memory to improve performance when retrieving values, at the cost of increased memory usage.defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
.
-
Create a new instance that stores the value against the
key
usingstorage
, defaulting todefaultValue
. Values stored will be processed by the provided transformer before being persisted and after being retrieved from the storage.Declaration
Swift
public init<Storage: Persist.Storage, Transformer: Persist.Transformer>( key: Storage.Key, storedBy storage: Storage, transformer: Transformer, cacheValue: Bool = false, defaultValue: @autoclosure @escaping () -> Value, defaultValuePersistBehaviour: DefaultValuePersistOption = [] ) where Transformer.Input == Value, Transformer.Output == Storage.Value
Parameters
key
The key to store the value against
storage
The storage to use to persist and retrieve the value.
transformer
A transformer to transform the value before being persisted and after being retrieved from the storage
cacheValue
When
true
the latest value will be cached in memory to improve performance when retrieving values, at the cost of increased memory usage.defaultValue
The value to use when a value has not yet been stored, or an error occurs.
defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
. -
Create a new instance that stores the value against the
key
usingstorage
, defaulting towrappedValue
. Values stored will be processed by the provided transformer before being persisted and after being retrieved from the storage.Declaration
Swift
public init<Storage: Persist.Storage, Transformer: Persist.Transformer>( wrappedValue: Value, key: Storage.Key, storedBy storage: Storage, transformer: Transformer, cacheValue: Bool = false, defaultValuePersistBehaviour: DefaultValuePersistOption = [] ) where Transformer.Input == Value, Transformer.Output == Storage.Value
Parameters
wrappedValue
The value to use when a value has not yet been stored, or an error occurs.
key
The key to store the value against
storage
The storage to use to persist and retrieve the value.
transformer
A transformer to transform the value before being persisted and after being retrieved from the storage
cacheValue
When
true
the latest value will be cached in memory to improve performance when retrieving values, at the cost of increased memory usage.defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
. -
Create a new instance that stores the value against the
key
usingstorage
, defaulting todefaultValue
. Values stored will be processed by the provided transformer before being persisted and after being retrieved from the storage.Declaration
Swift
public init<Storage: Persist.Storage, Transformer: Persist.Transformer, WrappedValue>( key: Storage.Key, storedBy storage: Storage, transformer: Transformer, cacheValue: Bool = false, defaultValue: @autoclosure @escaping () -> Value = nil, defaultValuePersistBehaviour: DefaultValuePersistOption = [] ) where Transformer.Input == WrappedValue, Transformer.Output == Storage.Value, Value == Optional<WrappedValue>
Parameters
key
The key to store the value against
storage
The storage to use to persist and retrieve the value.
transformer
A transformer to transform the value before being persisted and after being retrieved from the storage
cacheValue
When
true
the latest value will be cached in memory to improve performance when retrieving values, at the cost of increased memory usage.defaultValue
The value to use when a value has not yet been stored, or an error occurs. Defaults to
nil
.defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
. -
Create a new instance that stores the value against the
key
usingstorage
, defaulting towrappedValue
. Values stored will be processed by the provided transformer before being persisted and after being retrieved from the storage.Declaration
Swift
public init<Storage: Persist.Storage, Transformer: Persist.Transformer, WrappedValue>( wrappedValue: Value, key: Storage.Key, storedBy storage: Storage, transformer: Transformer, cacheValue: Bool = false, defaultValuePersistBehaviour: DefaultValuePersistOption = [] ) where Transformer.Input == WrappedValue, Transformer.Output == Storage.Value, Value == Optional<WrappedValue>
Parameters
wrappedValue
The value to use when a value has not yet been stored, or an error occurs.
key
The key to store the value against
storage
The storage to use to persist and retrieve the value.
transformer
A transformer to transform the value before being persisted and after being retrieved from the storage
cacheValue
When
true
the latest value will be cached in memory to improve performance when retrieving values, at the cost of increased memory usage.defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
. -
Create a new instance that stores the value against the
key
, storing values using the specifiedFileManager
, defaulting todefaultValue
.Values stored will be processed by the provided transformer before being persisted and after being retrieved from the storage.
Declaration
Swift
public init<Transformer: Persist.Transformer>( key: URL, storedBy fileManager: FileManager, transformer: Transformer, defaultValue: @autoclosure @escaping () -> Value, defaultValuePersistBehaviour: DefaultValuePersistOption = [] ) where Transformer.Input == Value, Transformer.Output == Data
Parameters
key
The key to store the value against
fileManager
The file manager to use to persist and retrieve the value.
transformer
A transformer to transform the value before being persisted and after being retrieved from the storage
defaultValue
The value to use when a value has not yet been stored, or an error occurs.
defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
. -
Create a new instance that stores the value against the
key
, storing values using the specifiedFileManager
, defaulting towrappedValue
.Values stored will be processed by the provided transformer before being persisted and after being retrieved from the storage.
Declaration
Swift
public init<Transformer: Persist.Transformer>( wrappedValue: Value, key: URL, storedBy fileManager: FileManager, transformer: Transformer, defaultValuePersistBehaviour: DefaultValuePersistOption = [] ) where Transformer.Input == Value, Transformer.Output == Data
Parameters
wrappedValue
The value to use when a value has not yet been stored, or an error occurs.
key
The key to store the value against
fileManager
The file manager to use to persist and retrieve the value.
transformer
A transformer to transform the value before being persisted and after being retrieved from the storage
defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
. -
Create a new instance that stores the value against the
key
, storing values using the specifiedFileManager
, defaulting todefaultValue
.Values stored will be processed by the provided transformer before being persisted and after being retrieved from the storage.
Declaration
Swift
public init<Transformer: Persist.Transformer>( key: URL, fileManager: FileManager, transformer: Transformer, defaultValue: @autoclosure @escaping () -> Value, defaultValuePersistBehaviour: DefaultValuePersistOption = [] ) where Transformer.Input == Value, Transformer.Output == Data
Parameters
key
The key to store the value against
fileManager
The file manager to use to persist and retrieve the value.
transformer
A transformer to transform the value before being persisted and after being retrieved from the storage
defaultValue
The value to use when a value has not yet been stored, or an error occurs.
defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
. -
Create a new instance that stores the value against the
key
, storing values using the specifiedFileManager
, defaulting towrappedValue
.Values stored will be processed by the provided transformer before being persisted and after being retrieved from the storage.
Declaration
Swift
public init<Transformer: Persist.Transformer>( wrappedValue: Value, key: URL, fileManager: FileManager, transformer: Transformer, defaultValuePersistBehaviour: DefaultValuePersistOption = [] ) where Transformer.Input == Value, Transformer.Output == Data
Parameters
wrappedValue
The value to use when a value has not yet been stored, or an error occurs.
key
The key to store the value against
fileManager
The file manager to use to persist and retrieve the value.
transformer
A transformer to transform the value before being persisted and after being retrieved from the storage
defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
. -
Create a new instance that stores the value against the
key
, storing values using the specifiedFileManager
, defaulting todefaultValue
.Values stored will be processed by the provided transformer before being persisted and after being retrieved from the storage.
Declaration
Swift
public init<Transformer: Persist.Transformer, WrappedValue>( key: URL, storedBy fileManager: FileManager, transformer: Transformer, defaultValue: @autoclosure @escaping () -> Value = nil, defaultValuePersistBehaviour: DefaultValuePersistOption = [] ) where Value == WrappedValue?, Transformer.Input == WrappedValue, Transformer.Output == Data
Parameters
key
The key to store the value against
fileManager
The file manager to use to persist and retrieve the value.
transformer
A transformer to transform the value before being persisted and after being retrieved from the storage
defaultValue
The value to use when a value has not yet been stored, or an error occurs. Defaults to
nil
.defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
. -
Create a new instance that stores the value against the
key
, storing values using the specifiedFileManager
, defaulting towrappedValue
.Values stored will be processed by the provided transformer before being persisted and after being retrieved from the storage.
Declaration
Swift
public init<Transformer: Persist.Transformer, WrappedValue>( wrappedValue: Value, key: URL, storedBy fileManager: FileManager, transformer: Transformer, defaultValuePersistBehaviour: DefaultValuePersistOption = [] ) where Value == WrappedValue?, Transformer.Input == WrappedValue, Transformer.Output == Data
Parameters
wrappedValue
The value to use when a value has not yet been stored, or an error occurs.
key
The key to store the value against
fileManager
The file manager to use to persist and retrieve the value.
transformer
A transformer to transform the value before being persisted and after being retrieved from the storage
defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
. -
Create a new instance that stores the value against the
key
, storing values using the specifiedFileManager
, defaulting todefaultValue
.Values stored will be processed by the provided transformer before being persisted and after being retrieved from the storage.
Declaration
Swift
public init<Transformer: Persist.Transformer, WrappedValue>( key: URL, fileManager: FileManager, transformer: Transformer, defaultValue: @autoclosure @escaping () -> Value = nil, defaultValuePersistBehaviour: DefaultValuePersistOption = [] ) where Value == WrappedValue?, Transformer.Input == WrappedValue, Transformer.Output == Data
Parameters
key
The key to store the value against
fileManager
The file manager to use to persist and retrieve the value.
transformer
A transformer to transform the value before being persisted and after being retrieved from the storage
defaultValue
The value to use when a value has not yet been stored, or an error occurs. Defaults to
nil
.defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
. -
Create a new instance that stores the value against the
key
, storing values using the specifiedFileManager
, defaulting towrappedValue
.Values stored will be processed by the provided transformer before being persisted and after being retrieved from the storage.
Declaration
Swift
public init<Transformer: Persist.Transformer, WrappedValue>( wrappedValue: Value, key: URL, fileManager: FileManager, transformer: Transformer, defaultValuePersistBehaviour: DefaultValuePersistOption = [] ) where Value == WrappedValue?, Transformer.Input == WrappedValue, Transformer.Output == Data
Parameters
wrappedValue
The value to use when a value has not yet been stored, or an error occurs.
key
The key to store the value against
fileManager
The file manager to use to persist and retrieve the value.
transformer
A transformer to transform the value before being persisted and after being retrieved from the storage
defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
.
-
Create a new instance that stores the value against the
key
, storing values in the specifiedNSUbiquitousKeyValueStore
, defaulting todefaultValue
.Declaration
Swift
public init<WrappedValue>( key: String, storedBy nsUbiquitousKeyValueStore: NSUbiquitousKeyValueStore, defaultValue: @autoclosure @escaping () -> Value = nil, defaultValuePersistBehaviour: DefaultValuePersistOption = [] ) where WrappedValue: StorableInNSUbiquitousKeyValueStore, Value == WrappedValue?
Parameters
key
The key to store the value against
nsUbiquitousKeyValueStore
The store to use to persist and retrieve the value.
defaultValue
The value to use when a value has not yet been stored, or an error occurs. Defaults to
nil
.defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
. -
Create a new instance that stores the value against the
key
, storing values in the specifiedNSUbiquitousKeyValueStore
, defaulting towrappedValue
.Declaration
Swift
public init<WrappedValue>( wrappedValue: Value, key: String, storedBy nsUbiquitousKeyValueStore: NSUbiquitousKeyValueStore, defaultValuePersistBehaviour: DefaultValuePersistOption = [] ) where WrappedValue: StorableInNSUbiquitousKeyValueStore, Value == WrappedValue?
Parameters
wrappedValue
The value to use when a value has not yet been stored, or an error occurs.
key
The key to store the value against
nsUbiquitousKeyValueStore
The store to use to persist and retrieve the value.
defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
. -
Create a new instance that stores the value against the
key
, storing values in the specifiedNSUbiquitousKeyValueStore
, defaulting todefaultValue
.Declaration
Swift
public init<WrappedValue>( key: String, nsUbiquitousKeyValueStore: NSUbiquitousKeyValueStore, defaultValue: @autoclosure @escaping () -> Value = nil, defaultValuePersistBehaviour: DefaultValuePersistOption = [] ) where WrappedValue: StorableInNSUbiquitousKeyValueStore, Value == WrappedValue?
Parameters
key
The key to store the value against
nsUbiquitousKeyValueStore
The store to use to persist and retrieve the value.
defaultValue
The value to use when a value has not yet been stored, or an error occurs. Defaults to
nil
.defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
. -
Create a new instance that stores the value against the
key
, storing values in the specifiedNSUbiquitousKeyValueStore
, defaulting towrappedValue
.Declaration
Swift
public init<WrappedValue>( wrappedValue: Value, key: String, nsUbiquitousKeyValueStore: NSUbiquitousKeyValueStore, defaultValuePersistBehaviour: DefaultValuePersistOption = [] ) where WrappedValue: StorableInNSUbiquitousKeyValueStore, Value == WrappedValue?
Parameters
key
The key to store the value against
nsUbiquitousKeyValueStore
The store to use to persist and retrieve the value.
wrappedValue
The value to use when a value has not yet been stored, or an error occurs.
defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
.
-
Create a new instance that stores the value against the
key
, storing values in the specifiedNSUbiquitousKeyValueStore
, defaulting todefaultValue
.Values stored will be processed by the provided transformer before being persisted and after being retrieved from the storage.
Declaration
Swift
public init<Transformer: Persist.Transformer>( key: String, storedBy nsUbiquitousKeyValueStore: NSUbiquitousKeyValueStore, transformer: Transformer, defaultValue: @autoclosure @escaping () -> Value, defaultValuePersistBehaviour: DefaultValuePersistOption = [] ) where Transformer.Input == Value, Transformer.Output: StorableInNSUbiquitousKeyValueStore
Parameters
key
The key to store the value against
nsUbiquitousKeyValueStore
The store to use to persist and retrieve the value.
transformer
A transformer to transform the value before being persisted and after being retrieved from the storage
defaultValue
The value to use when a value has not yet been stored, or an error occurs.
defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
. -
Create a new instance that stores the value against the
key
, storing values in the specifiedNSUbiquitousKeyValueStore
, defaulting towrappedValue
.Values stored will be processed by the provided transformer before being persisted and after being retrieved from the storage.
Declaration
Swift
public init<Transformer: Persist.Transformer>( wrappedValue: Value, key: String, storedBy nsUbiquitousKeyValueStore: NSUbiquitousKeyValueStore, transformer: Transformer, defaultValuePersistBehaviour: DefaultValuePersistOption = [] ) where Transformer.Input == Value, Transformer.Output: StorableInNSUbiquitousKeyValueStore
Parameters
wrappedValue
The value to use when a value has not yet been stored, or an error occurs.
key
The key to store the value against
nsUbiquitousKeyValueStore
The store to use to persist and retrieve the value.
transformer
A transformer to transform the value before being persisted and after being retrieved from the storage
defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
. -
Create a new instance that stores the value against the
key
, storing values in the specifiedNSUbiquitousKeyValueStore
, defaulting todefaultValue
.Values stored will be processed by the provided transformer before being persisted and after being retrieved from the storage.
Declaration
Swift
public init<Transformer: Persist.Transformer>( key: String, nsUbiquitousKeyValueStore: NSUbiquitousKeyValueStore, transformer: Transformer, defaultValue: @autoclosure @escaping () -> Value, defaultValuePersistBehaviour: DefaultValuePersistOption = [] ) where Transformer.Input == Value, Transformer.Output: StorableInNSUbiquitousKeyValueStore
Parameters
key
The key to store the value against
nsUbiquitousKeyValueStore
The store to use to persist and retrieve the value.
transformer
A transformer to transform the value before being persisted and after being retrieved from the storage
defaultValue
The value to use when a value has not yet been stored, or an error occurs.
defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
. -
Create a new instance that stores the value against the
key
, storing values in the specifiedNSUbiquitousKeyValueStore
, defaulting towrappedValue
.Values stored will be processed by the provided transformer before being persisted and after being retrieved from the storage.
Declaration
Swift
public init<Transformer: Persist.Transformer>( wrappedValue: Value, key: String, nsUbiquitousKeyValueStore: NSUbiquitousKeyValueStore, transformer: Transformer, defaultValuePersistBehaviour: DefaultValuePersistOption = [] ) where Transformer.Input == Value, Transformer.Output: StorableInNSUbiquitousKeyValueStore
Parameters
wrappedValue
The value to use when a value has not yet been stored, or an error occurs.
key
The key to store the value against
nsUbiquitousKeyValueStore
The store to use to persist and retrieve the value.
transformer
A transformer to transform the value before being persisted and after being retrieved from the storage
defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
.
-
Create a new instance that stores the value against the
key
, storing values in the specifiedNSUbiquitousKeyValueStore
, defaulting todefaultValue
.Values stored will be processed by the provided transformer before being persisted and after being retrieved from the storage.
Declaration
Swift
public init<Transformer: Persist.Transformer, WrappedValue>( key: String, storedBy nsUbiquitousKeyValueStore: NSUbiquitousKeyValueStore, transformer: Transformer, defaultValue: @autoclosure @escaping () -> Value = nil, defaultValuePersistBehaviour: DefaultValuePersistOption = [] ) where Transformer.Input == WrappedValue, Transformer.Output: StorableInNSUbiquitousKeyValueStore, Value == WrappedValue?
Parameters
key
The key to store the value against
nsUbiquitousKeyValueStore
The store to use to persist and retrieve the value.
transformer
A transformer to transform the value before being persisted and after being retrieved from the storage
defaultValue
The value to use when a value has not yet been stored, or an error occurs. Defaults to
nil
.defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
. -
Create a new instance that stores the value against the
key
, storing values in the specifiedNSUbiquitousKeyValueStore
, defaulting towrappedValue
.Values stored will be processed by the provided transformer before being persisted and after being retrieved from the storage.
Declaration
Swift
public init<Transformer: Persist.Transformer, WrappedValue>( wrappedValue: Value, key: String, storedBy nsUbiquitousKeyValueStore: NSUbiquitousKeyValueStore, transformer: Transformer, defaultValuePersistBehaviour: DefaultValuePersistOption = [] ) where Transformer.Input == WrappedValue, Transformer.Output: StorableInNSUbiquitousKeyValueStore, Value == WrappedValue?
Parameters
wrappedValue
The value to use when a value has not yet been stored, or an error occurs.
key
The key to store the value against
nsUbiquitousKeyValueStore
The store to use to persist and retrieve the value.
transformer
A transformer to transform the value before being persisted and after being retrieved from the storage
defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
. -
Create a new instance that stores the value against the
key
, storing values in the specifiedNSUbiquitousKeyValueStore
, defaulting todefaultValue
.Values stored will be processed by the provided transformer before being persisted and after being retrieved from the storage.
Declaration
Swift
public init<Transformer: Persist.Transformer, WrappedValue>( key: String, nsUbiquitousKeyValueStore: NSUbiquitousKeyValueStore, transformer: Transformer, defaultValue: @autoclosure @escaping () -> Value = nil, defaultValuePersistBehaviour: DefaultValuePersistOption = [] ) where Transformer.Input == WrappedValue, Transformer.Output: StorableInNSUbiquitousKeyValueStore, Value == WrappedValue?
Parameters
key
The key to store the value against
nsUbiquitousKeyValueStore
The store to use to persist and retrieve the value.
transformer
A transformer to transform the value before being persisted and after being retrieved from the storage
defaultValue
The value to use when a value has not yet been stored, or an error occurs. Defaults to
nil
.defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
. -
Create a new instance that stores the value against the
key
, storing values in the specifiedNSUbiquitousKeyValueStore
, defaulting towrappedValue
.Values stored will be processed by the provided transformer before being persisted and after being retrieved from the storage.
Declaration
Swift
public init<Transformer: Persist.Transformer, WrappedValue>( wrappedValue: Value, key: String, nsUbiquitousKeyValueStore: NSUbiquitousKeyValueStore, transformer: Transformer, defaultValuePersistBehaviour: DefaultValuePersistOption = [] ) where Transformer.Input == WrappedValue, Transformer.Output: StorableInNSUbiquitousKeyValueStore, Value == WrappedValue?
Parameters
wrappedValue
The value to use when a value has not yet been stored, or an error occurs.
key
The key to store the value against
nsUbiquitousKeyValueStore
The store to use to persist and retrieve the value.
transformer
A transformer to transform the value before being persisted and after being retrieved from the storage
defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
.
-
Create a new instance that stores the value against the
key
, storing values in the specifiedUserDefaults
, defaulting todefaultValue
.Declaration
Swift
public init<WrappedValue>( key: String, storedBy userDefaults: UserDefaults, cacheValue: Bool = false, defaultValue: @autoclosure @escaping () -> Value = nil, defaultValuePersistBehaviour: DefaultValuePersistOption = [] ) where WrappedValue: StorableInUserDefaults, Value == WrappedValue?
Parameters
key
The key to store the value against
userDefaults
The user defaults to use to persist and retrieve the value.
cacheValue
When
true
the latest value will be cached in memory to improve performance when retrieving values, at the cost of increased memory usage.defaultValue
The value to use when a value has not yet been stored, or an error occurs. Defaults to
nil
.defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
. -
Create a new instance that stores the value against the
key
, storing values in the specifiedUserDefaults
, defaulting towrappedValue
.Declaration
Swift
public init<WrappedValue>( wrappedValue: Value, key: String, storedBy userDefaults: UserDefaults, cacheValue: Bool = false, defaultValuePersistBehaviour: DefaultValuePersistOption = [] ) where WrappedValue: StorableInUserDefaults, Value == WrappedValue?
Parameters
wrappedValue
The value to use when a value has not yet been stored, or an error occurs.
key
The key to store the value against
userDefaults
The user defaults to use to persist and retrieve the value.
cacheValue
When
true
the latest value will be cached in memory to improve performance when retrieving values, at the cost of increased memory usage.defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
. -
Create a new instance that stores the value against the
key
, storing values in the specifiedUserDefaults
, defaulting todefaultValue
.Declaration
Swift
public init<WrappedValue>( key: String, userDefaults: UserDefaults, cacheValue: Bool = false, defaultValue: @autoclosure @escaping () -> Value = nil, defaultValuePersistBehaviour: DefaultValuePersistOption = [] ) where WrappedValue: StorableInUserDefaults, Value == WrappedValue?
Parameters
key
The key to store the value against
userDefaults
The user defaults to use to persist and retrieve the value.
cacheValue
When
true
the latest value will be cached in memory to improve performance when retrieving values, at the cost of increased memory usage.defaultValue
The value to use when a value has not yet been stored, or an error occurs. Defaults to
nil
.defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
. -
Create a new instance that stores the value against the
key
, storing values in the specifiedUserDefaults
, defaulting towrappedValue
.Declaration
Swift
public init<WrappedValue>( wrappedValue: Value, key: String, userDefaults: UserDefaults, cacheValue: Bool = false, defaultValuePersistBehaviour: DefaultValuePersistOption = [] ) where WrappedValue: StorableInUserDefaults, Value == WrappedValue?
Parameters
wrappedValue
The value to use when a value has not yet been stored, or an error occurs.
key
The key to store the value against
userDefaults
The user defaults to use to persist and retrieve the value.
cacheValue
When
true
the latest value will be cached in memory to improve performance when retrieving values, at the cost of increased memory usage.defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
.
-
Create a new instance that stores the value against the
key
, storing values in the specifiedUserDefaults
, defaulting todefaultValue
.Values stored will be processed by the provided transformer before being persisted and after being retrieved from the storage.
Declaration
Swift
public init<Transformer: Persist.Transformer>( key: String, storedBy userDefaults: UserDefaults, transformer: Transformer, cacheValue: Bool = false, defaultValue: @autoclosure @escaping () -> Value, defaultValuePersistBehaviour: DefaultValuePersistOption = [] ) where Transformer.Input == Value, Transformer.Output: StorableInUserDefaults
Parameters
key
The key to store the value against
userDefaults
The user defaults to use to persist and retrieve the value.
transformer
A transformer to transform the value before being persisted and after being retrieved from the storage
cacheValue
When
true
the latest value will be cached in memory to improve performance when retrieving values, at the cost of increased memory usage.defaultValue
The value to use when a value has not yet been stored, or an error occurs.
defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
. -
Create a new instance that stores the value against the
key
, storing values in the specifiedUserDefaults
, defaulting towrappedValue
.Values stored will be processed by the provided transformer before being persisted and after being retrieved from the storage.
Declaration
Swift
public init<Transformer: Persist.Transformer>( wrappedValue: Value, key: String, storedBy userDefaults: UserDefaults, transformer: Transformer, cacheValue: Bool = false, defaultValuePersistBehaviour: DefaultValuePersistOption = [] ) where Transformer.Input == Value, Transformer.Output: StorableInUserDefaults
Parameters
key
The key to store the value against
userDefaults
The user defaults to use to persist and retrieve the value.
transformer
A transformer to transform the value before being persisted and after being retrieved from the storage
cacheValue
When
true
the latest value will be cached in memory to improve performance when retrieving values, at the cost of increased memory usage.wrappedValue
The value to use when a value has not yet been stored, or an error occurs.
defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
. -
Create a new instance that stores the value against the
key
, storing values in the specifiedUserDefaults
, defaulting todefaultValue
.Values stored will be processed by the provided transformer before being persisted and after being retrieved from the storage.
Declaration
Swift
public init<Transformer: Persist.Transformer>( key: String, userDefaults: UserDefaults, transformer: Transformer, cacheValue: Bool = false, defaultValue: @autoclosure @escaping () -> Value, defaultValuePersistBehaviour: DefaultValuePersistOption = [] ) where Transformer.Input == Value, Transformer.Output: StorableInUserDefaults
Parameters
key
The key to store the value against
userDefaults
The user defaults to use to persist and retrieve the value.
transformer
A transformer to transform the value before being persisted and after being retrieved from the storage
cacheValue
When
true
the latest value will be cached in memory to improve performance when retrieving values, at the cost of increased memory usage.defaultValue
The value to use when a value has not yet been stored, or an error occurs.
defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
. -
Create a new instance that stores the value against the
key
, storing values in the specifiedUserDefaults
, defaulting towrappedValue
.Values stored will be processed by the provided transformer before being persisted and after being retrieved from the storage.
Declaration
Swift
public init<Transformer: Persist.Transformer>( wrappedValue: Value, key: String, userDefaults: UserDefaults, transformer: Transformer, cacheValue: Bool = false, defaultValuePersistBehaviour: DefaultValuePersistOption = [] ) where Transformer.Input == Value, Transformer.Output: StorableInUserDefaults
Parameters
wrappedValue
The value to use when a value has not yet been stored, or an error occurs.
key
The key to store the value against
userDefaults
The user defaults to use to persist and retrieve the value.
transformer
A transformer to transform the value before being persisted and after being retrieved from the storage
cacheValue
When
true
the latest value will be cached in memory to improve performance when retrieving values, at the cost of increased memory usage.defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
.
-
Create a new instance that stores the value against the
key
, storing values in the specifiedUserDefaults
, defaulting todefaultValue
.Values stored will be processed by the provided transformer before being persisted and after being retrieved from the storage.
Declaration
Swift
public init<Transformer: Persist.Transformer, WrappedValue>( key: String, storedBy userDefaults: UserDefaults, transformer: Transformer, cacheValue: Bool = false, defaultValue: @autoclosure @escaping () -> Value = nil, defaultValuePersistBehaviour: DefaultValuePersistOption = [] ) where Transformer.Input == WrappedValue, Transformer.Output: StorableInUserDefaults, Value == WrappedValue?
Parameters
key
The key to store the value against
userDefaults
The user defaults to use to persist and retrieve the value.
transformer
A transformer to transform the value before being persisted and after being retrieved from the storage
cacheValue
When
true
the latest value will be cached in memory to improve performance when retrieving values, at the cost of increased memory usage.defaultValue
The value to use when a value has not yet been stored, or an error occurs. Defaults to
nil
.defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
. -
Create a new instance that stores the value against the
key
, storing values in the specifiedUserDefaults
, defaulting towrappedValue
.Values stored will be processed by the provided transformer before being persisted and after being retrieved from the storage.
Declaration
Swift
public init<Transformer: Persist.Transformer, WrappedValue>( wrappedValue: Value, key: String, storedBy userDefaults: UserDefaults, transformer: Transformer, cacheValue: Bool = false, defaultValuePersistBehaviour: DefaultValuePersistOption = [] ) where Transformer.Input == WrappedValue, Transformer.Output: StorableInUserDefaults, Value == WrappedValue?
Parameters
wrappedValue
The value to use when a value has not yet been stored, or an error occurs.
key
The key to store the value against
userDefaults
The user defaults to use to persist and retrieve the value.
transformer
A transformer to transform the value before being persisted and after being retrieved from the storage
cacheValue
When
true
the latest value will be cached in memory to improve performance when retrieving values, at the cost of increased memory usage.defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
. -
Create a new instance that stores the value against the
key
, storing values in the specifiedUserDefaults
, defaulting todefaultValue
.Values stored will be processed by the provided transformer before being persisted and after being retrieved from the storage.
Declaration
Swift
public init<Transformer: Persist.Transformer, WrappedValue>( key: String, userDefaults: UserDefaults, transformer: Transformer, cacheValue: Bool = false, defaultValue: @autoclosure @escaping () -> Value = nil, defaultValuePersistBehaviour: DefaultValuePersistOption = [] ) where Transformer.Input == WrappedValue, Transformer.Output: StorableInUserDefaults, Value == WrappedValue?
Parameters
key
The key to store the value against
userDefaults
The user defaults to use to persist and retrieve the value.
transformer
A transformer to transform the value before being persisted and after being retrieved from the storage
cacheValue
When
true
the latest value will be cached in memory to improve performance when retrieving values, at the cost of increased memory usage.defaultValue
The value to use when a value has not yet been stored, or an error occurs. Defaults to
nil
.defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
. -
Create a new instance that stores the value against the
key
, storing values in the specifiedUserDefaults
, defaulting towrappedValue
.Values stored will be processed by the provided transformer before being persisted and after being retrieved from the storage.
Declaration
Swift
public init<Transformer: Persist.Transformer, WrappedValue>( wrappedValue: Value, key: String, userDefaults: UserDefaults, transformer: Transformer, cacheValue: Bool = false, defaultValuePersistBehaviour: DefaultValuePersistOption = [] ) where Transformer.Input == WrappedValue, Transformer.Output: StorableInUserDefaults, Value == WrappedValue?
Parameters
wrappedValue
The value to use when a value has not yet been stored, or an error occurs.
key
The key to store the value against
userDefaults
The user defaults to use to persist and retrieve the value.
transformer
A transformer to transform the value before being persisted and after being retrieved from the storage
cacheValue
When
true
the latest value will be cached in memory to improve performance when retrieving values, at the cost of increased memory usage.defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
.
-
Create a new instance that stores the value against the
key
, storing values using the specifiedFileManager
, defaulting todefaultValue
.Declaration
Swift
public init( key: URL, storedBy fileManager: FileManager, defaultValue: @autoclosure @escaping () -> Value, defaultValuePersistBehaviour: DefaultValuePersistOption = [] )
Parameters
key
The key to store the value against
fileManager
The file manager to use to persist and retrieve the value.
defaultValue
The value to use when a value has not yet been stored, or an error occurs.
defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
. -
Create a new instance that stores the value against the
key
, storing values using the specifiedFileManager
, defaulting towrappedValue
.Declaration
Swift
public init( wrappedValue: Value, key: URL, storedBy fileManager: FileManager, defaultValuePersistBehaviour: DefaultValuePersistOption = [] )
Parameters
wrappedValue
The value to use when a value has not yet been stored, or an error occurs.
key
The key to store the value against
fileManager
The file manager to use to persist and retrieve the value.
defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
. -
Create a new instance that stores the value against the
key
, storing values using the specifiedFileManager
, defaulting todefaultValue
.Declaration
Swift
public init( key: URL, fileManager: FileManager, defaultValue: @autoclosure @escaping () -> Value, defaultValuePersistBehaviour: DefaultValuePersistOption = [] )
Parameters
key
The key to store the value against
fileManager
The file manager to use to persist and retrieve the value.
defaultValue
The value to use when a value has not yet been stored, or an error occurs.
defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
. -
Create a new instance that stores the value against the
key
, storing values using the specifiedFileManager
, defaulting towrappedValue
.Declaration
Swift
public init( wrappedValue: Value, key: URL, fileManager: FileManager, defaultValuePersistBehaviour: DefaultValuePersistOption = [] )
Parameters
wrappedValue
The value to use when a value has not yet been stored, or an error occurs.
key
The key to store the value against
fileManager
The file manager to use to persist and retrieve the value.
defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
.
-
Create a new instance that stores the value against the
key
, storing values using the specifiedFileManager
, defaulting todefaultValue
.Declaration
Swift
public init( key: URL, storedBy fileManager: FileManager, defaultValue: @autoclosure @escaping () -> Value = nil, defaultValuePersistBehaviour: DefaultValuePersistOption = [] )
Parameters
key
The key to store the value against
fileManager
The file manager to use to persist and retrieve the value.
defaultValue
The value to use when a value has not yet been stored, or an error occurs. Defaults to
nil
.defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
. -
Create a new instance that stores the value against the
key
, storing values using the specifiedFileManager
, defaulting towrappedValue
.Declaration
Swift
public init( wrappedValue: Value, key: URL, storedBy fileManager: FileManager, defaultValuePersistBehaviour: DefaultValuePersistOption = [] )
Parameters
wrappedValue
The value to use when a value has not yet been stored, or an error occurs.
key
The key to store the value against
fileManager
The file manager to use to persist and retrieve the value.
defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
. -
Create a new instance that stores the value against the
key
, storing values using the specifiedFileManager
, defaulting todefaultValue
.Declaration
Swift
public init( key: URL, fileManager: FileManager, defaultValue: @autoclosure @escaping () -> Value = nil, defaultValuePersistBehaviour: DefaultValuePersistOption = [] )
Parameters
key
The key to store the value against
fileManager
The file manager to use to persist and retrieve the value.
defaultValue
The value to use when a value has not yet been stored, or an error occurs. Defaults to
nil
.defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
. -
Create a new instance that stores the value against the
key
, storing values using the specifiedFileManager
, defaulting towrappedValue
.Declaration
Swift
public init( wrappedValue: Value, key: URL, fileManager: FileManager, defaultValuePersistBehaviour: DefaultValuePersistOption = [] )
Parameters
wrappedValue
The value to use when a value has not yet been stored, or an error occurs.
key
The key to store the value against
fileManager
The file manager to use to persist and retrieve the value.
defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
.
-
Create a new instance that stores the value against the
key
, storing values in the specifiedNSUbiquitousKeyValueStore
, defaulting todefaultValue
.Declaration
Swift
public init( key: String, storedBy nsUbiquitousKeyValueStore: NSUbiquitousKeyValueStore, defaultValue: @autoclosure @escaping () -> Value, defaultValuePersistBehaviour: DefaultValuePersistOption = [] )
Parameters
key
The key to store the value against
nsUbiquitousKeyValueStore
The store to use to persist and retrieve the value.
defaultValue
The value to use when a value has not yet been stored, or an error occurs.
defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
. -
Create a new instance that stores the value against the
key
, storing values in the specifiedNSUbiquitousKeyValueStore
, defaulting towrappedValue
.Declaration
Swift
public init( wrappedValue: Value, key: String, storedBy nsUbiquitousKeyValueStore: NSUbiquitousKeyValueStore, defaultValuePersistBehaviour: DefaultValuePersistOption = [] )
Parameters
wrappedValue
The value to use when a value has not yet been stored, or an error occurs.
key
The key to store the value against
nsUbiquitousKeyValueStore
The store to use to persist and retrieve the value.
defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
. -
Create a new instance that stores the value against the
key
, storing values in the specifiedNSUbiquitousKeyValueStore
, defaulting todefaultValue
.Declaration
Swift
public init( key: String, nsUbiquitousKeyValueStore: NSUbiquitousKeyValueStore, defaultValue: @autoclosure @escaping () -> Value, defaultValuePersistBehaviour: DefaultValuePersistOption = [] )
Parameters
key
The key to store the value against
nsUbiquitousKeyValueStore
The store to use to persist and retrieve the value.
defaultValue
The value to use when a value has not yet been stored, or an error occurs.
defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
. -
Create a new instance that stores the value against the
key
, storing values in the specifiedNSUbiquitousKeyValueStore
, defaulting towrappedValue
.Declaration
Swift
public init( wrappedValue: Value, key: String, nsUbiquitousKeyValueStore: NSUbiquitousKeyValueStore, defaultValuePersistBehaviour: DefaultValuePersistOption = [] )
Parameters
wrappedValue
The value to use when a value has not yet been stored, or an error occurs.
key
The key to store the value against
nsUbiquitousKeyValueStore
The store to use to persist and retrieve the value.
defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
.
-
Create a new instance that stores the value against the
key
, storing values in the specifiedUserDefaults
, defaulting todefaultValue
.Declaration
Swift
public init( key: String, storedBy userDefaults: UserDefaults, cacheValue: Bool = false, defaultValue: @autoclosure @escaping () -> Value, defaultValuePersistBehaviour: DefaultValuePersistOption = [] )
Parameters
key
The key to store the value against
userDefaults
The user defaults to use to persist and retrieve the value.
cacheValue
When
true
the latest value will be cached in memory to improve performance when retrieving values, at the cost of increased memory usage.defaultValue
The value to use when a value has not yet been stored, or an error occurs.
defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
. -
Create a new instance that stores the value against the
key
, storing values in the specifiedUserDefaults
, defaulting towrappedValue
.Declaration
Swift
public init( wrappedValue: Value, key: String, storedBy userDefaults: UserDefaults, cacheValue: Bool = false, defaultValuePersistBehaviour: DefaultValuePersistOption = [] )
Parameters
wrappedValue
The value to use when a value has not yet been stored, or an error occurs.
key
The key to store the value against
userDefaults
The user defaults to use to persist and retrieve the value.
cacheValue
When
true
the latest value will be cached in memory to improve performance when retrieving values, at the cost of increased memory usage.defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
. -
Create a new instance that stores the value against the
key
, storing values in the specifiedUserDefaults
, defaulting todefaultValue
.Declaration
Swift
public init( key: String, userDefaults: UserDefaults, cacheValue: Bool = false, defaultValue: @autoclosure @escaping () -> Value, defaultValuePersistBehaviour: DefaultValuePersistOption = [] )
Parameters
key
The key to store the value against
userDefaults
The user defaults to use to persist and retrieve the value.
cacheValue
When
true
the latest value will be cached in memory to improve performance when retrieving values, at the cost of increased memory usage.defaultValue
The value to use when a value has not yet been stored, or an error occurs.
defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
. -
Create a new instance that stores the value against the
key
, storing values in the specifiedUserDefaults
, defaulting towrappedValue
.Declaration
Swift
public init( wrappedValue: Value, key: String, userDefaults: UserDefaults, cacheValue: Bool = false, defaultValuePersistBehaviour: DefaultValuePersistOption = [] )
Parameters
wrappedValue
The value to use when a value has not yet been stored, or an error occurs.
key
The key to store the value against
userDefaults
The user defaults to use to persist and retrieve the value.
cacheValue
When
true
the latest value will be cached in memory to improve performance when retrieving values, at the cost of increased memory usage.defaultValuePersistBehaviour
An option set that describes when to persist the default value. Defaults to
[]
.