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 }
  • The Persister used to persist and retrieve the value.

    Declaration

    Swift

    public private(set) var projectedValue: Persister<Value> { get }
  • Create a new instance that uses the provided Persister to persist and retrieve the value.

    Declaration

    Swift

    public init(persister: Persister<Value>)

Storage.Value == Value

  • Create a new instance that stores the value against the key using storage, defaulting to defaultValue.

    Declaration

    Swift

    public init<Storage: Persist.Storage>(
        key: Storage.Key,
        storedBy storage: Storage,
        cacheValue: Bool = false,
        defaultValue: @autoclosure @escaping () -> Value,
        defaultValuePersistBehaviour: DefaultValuePersistOption = []
    ) where Storage.Value == Value

    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 using storage, defaulting to wrappedValue.

    Declaration

    Swift

    public init<Storage: Persist.Storage>(
        wrappedValue: Value,
        key: Storage.Key,
        storedBy storage: Storage,
        cacheValue: Bool = false,
        defaultValuePersistBehaviour: DefaultValuePersistOption = []
    ) where Storage.Value == 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.

    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 using storage, defaulting to defaultValue.

    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 using storage, defaulting to wrappedValue.

    Declaration

    Swift

    public init<Storage: Persist.Storage, WrappedValue>(
        wrappedValue: Value,
        key: Storage.Key,
        storedBy storage: Storage,
        cacheValue: Bool = false,
        defaultValuePersistBehaviour: DefaultValuePersistOption = []
    ) where Storage.Value == WrappedValue, 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.

    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 [].

Storage.Value == Any

  • Create a new instance that stores the value against the key using storage, defaulting to defaultValue.

    Declaration

    Swift

    public init<Storage: Persist.Storage>(
        key: Storage.Key,
        storedBy storage: Storage,
        cacheValue: Bool = false,
        defaultValue: @autoclosure @escaping () -> Value,
        defaultValuePersistBehaviour: DefaultValuePersistOption = []
    ) where Storage.Value == Any

    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 using storage, defaulting to wrappedValue.

    Declaration

    Swift

    public init<Storage: Persist.Storage>(
        wrappedValue: Value,
        key: Storage.Key,
        storedBy storage: Storage,
        cacheValue: Bool = false,
        defaultValuePersistBehaviour: DefaultValuePersistOption = []
    ) where Storage.Value == Any

    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 using storage, defaulting to defaultValue.

    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 using storage, defaulting to wrappedValue.

    Declaration

    Swift

    public init<Storage: Persist.Storage, WrappedValue>(
        wrappedValue: Value,
        key: Storage.Key,
        storedBy storage: Storage,
        cacheValue: Bool = false,
        defaultValuePersistBehaviour: DefaultValuePersistOption = []
    ) where Storage.Value == Any, 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.

    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 [].

Storage.Value == Any, Transformer.Input == Value

  • Create a new instance that stores the value against the key using storage, defaulting to defaultValue. 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 using storage, defaulting to defaultValue. 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 using storage, defaulting to defaultValue. 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 using storage, defaulting to wrappedValue. 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 [].

Transformer.Input == Value, Transformer.Output == Storage.Value

  • Create a new instance that stores the value against the key using storage, defaulting to defaultValue. 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 using storage, defaulting to wrappedValue. 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 using storage, defaulting to defaultValue. 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 using storage, defaulting to wrappedValue. 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 specified FileManager, defaulting to defaultValue.

    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 specified FileManager, defaulting to wrappedValue.

    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 specified FileManager, defaulting to defaultValue.

    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 specified FileManager, defaulting to wrappedValue.

    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 specified FileManager, defaulting to defaultValue.

    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 specified FileManager, defaulting to wrappedValue.

    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 specified FileManager, defaulting to defaultValue.

    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 specified FileManager, defaulting to wrappedValue.

    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 [].

Value: StorableInNSUbiquitousKeyValueStore?

  • Create a new instance that stores the value against the key, storing values in the specified NSUbiquitousKeyValueStore, defaulting to defaultValue.

    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 specified NSUbiquitousKeyValueStore, defaulting to wrappedValue.

    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 specified NSUbiquitousKeyValueStore, defaulting to defaultValue.

    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 specified NSUbiquitousKeyValueStore, defaulting to wrappedValue.

    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 [].

Transformer.Input == Value, Transformer.Output: StorableInNSUbiquitousKeyValueStore

  • Create a new instance that stores the value against the key, storing values in the specified NSUbiquitousKeyValueStore, defaulting to defaultValue.

    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 specified NSUbiquitousKeyValueStore, defaulting to wrappedValue.

    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 specified NSUbiquitousKeyValueStore, defaulting to defaultValue.

    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 specified NSUbiquitousKeyValueStore, defaulting to wrappedValue.

    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 [].

Transformer.Input == WrappedValue, Transformer.Output: StorableInNSUbiquitousKeyValueStore

  • Create a new instance that stores the value against the key, storing values in the specified NSUbiquitousKeyValueStore, defaulting to defaultValue.

    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 specified NSUbiquitousKeyValueStore, defaulting to wrappedValue.

    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 specified NSUbiquitousKeyValueStore, defaulting to defaultValue.

    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 specified NSUbiquitousKeyValueStore, defaulting to wrappedValue.

    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 [].

Value: StorableInUserDefaults?

  • Create a new instance that stores the value against the key, storing values in the specified UserDefaults, defaulting to defaultValue.

    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 specified UserDefaults, defaulting to wrappedValue.

    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 specified UserDefaults, defaulting to defaultValue.

    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 specified UserDefaults, defaulting to wrappedValue.

    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 [].

Transformer.Input == Value, Transformer.Output: StorableInUserDefaults

  • Create a new instance that stores the value against the key, storing values in the specified UserDefaults, defaulting to defaultValue.

    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 specified UserDefaults, defaulting to wrappedValue.

    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 specified UserDefaults, defaulting to defaultValue.

    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 specified UserDefaults, defaulting to wrappedValue.

    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 [].

Transformer.Input == WrappedValue, Transformer.Output: StorableInUserDefaults

  • Create a new instance that stores the value against the key, storing values in the specified UserDefaults, defaulting to defaultValue.

    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 specified UserDefaults, defaulting to wrappedValue.

    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 specified UserDefaults, defaulting to defaultValue.

    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 specified UserDefaults, defaulting to wrappedValue.

    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 [].

Available where Value == Data

  • Create a new instance that stores the value against the key, storing values using the specified FileManager, defaulting to defaultValue.

    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 specified FileManager, defaulting to wrappedValue.

    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 specified FileManager, defaulting to defaultValue.

    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 specified FileManager, defaulting to wrappedValue.

    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 [].

Available where Value == Data?

  • Create a new instance that stores the value against the key, storing values using the specified FileManager, defaulting to defaultValue.

    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 specified FileManager, defaulting to wrappedValue.

    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 specified FileManager, defaulting to defaultValue.

    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 specified FileManager, defaulting to wrappedValue.

    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 [].

Available where Value: StorableInNSUbiquitousKeyValueStore

  • Create a new instance that stores the value against the key, storing values in the specified NSUbiquitousKeyValueStore, defaulting to defaultValue.

    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 specified NSUbiquitousKeyValueStore, defaulting to wrappedValue.

    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 specified NSUbiquitousKeyValueStore, defaulting to defaultValue.

    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 specified NSUbiquitousKeyValueStore, defaulting to wrappedValue.

    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 [].

Available where Value: StorableInUserDefaults

  • Create a new instance that stores the value against the key, storing values in the specified UserDefaults, defaulting to defaultValue.

    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 specified UserDefaults, defaulting to wrappedValue.

    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 specified UserDefaults, defaulting to defaultValue.

    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 specified UserDefaults, defaulting to wrappedValue.

    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 [].