appStorage(_:store:)
Creates a shared key that can read and write to a date user default.
static func appStorage(_ key: String, store: UserDefaults? = nil) -> Self where Self == AppStorageKey<Date>
Parameters
Returns
A user defaults shared key.
Creates a shared key that can read and write to a date user default.
static func appStorage(_ key: String, store: UserDefaults? = nil) -> Self where Self == AppStorageKey<Date>
s7Sharing15SharedReaderKeyPAAE10appStorage_5storeAA03AppfD0Vy10Foundation4DateVGSS_So14NSUserDefaultsCSgtAKRszrlFZ
What are these?3DTM
A user defaults shared key.
import Sharing
Instantly share state among your app’s features and external persistence layers, including user defaults, the file system, and more.
protocol SharedReaderKey<Value> : Sendable
A type that can load and subscribe to state in an external system.
@frozen struct String
A Unicode string value that is a collection of characters.
struct AppStorageKey<Value> where Value : Sendable
A type defining a user defaults persistence strategy.
static func appStorage(_ key: String, store: UserDefaults? = nil) -> Self where Self == AppStorageKey<URL>
Creates a shared key that can read and write to a URL user default.
static func appStorage(_ key: String, store: UserDefaults? = nil) -> Self where Self == AppStorageKey<URL?>
Creates a shared key that can read and write to an optional URL user default.
static func appStorage(_ key: String, store: UserDefaults? = nil) -> Self where Self == AppStorageKey<Data>
Creates a shared key that can read and write to a user default as data.
static func appStorage(_ key: String, store: UserDefaults? = nil) -> Self where Self == AppStorageKey<Data?>
Creates a shared key that can read and write to a user default as optional data.
static func appStorage(_ key: String, store: UserDefaults? = nil) -> Self where Self == AppStorageKey<Date?>
Creates a shared key that can read and write to an optional date user default.
static func appStorage(_ key: String, store: UserDefaults? = nil) -> Self where Self == AppStorageKey<String>
Creates a shared key that can read and write to a string user default.
static func appStorage(_ key: String, store: UserDefaults? = nil) -> Self where Self == AppStorageKey<String?>
Creates a shared key that can read and write to an optional string user default.
static func appStorage(_ key: String, store: UserDefaults? = nil) -> Self where Self == AppStorageKey<Bool>
Creates a shared key that can read and write to a boolean user default.
static func appStorage(_ key: String, store: UserDefaults? = nil) -> Self where Self == AppStorageKey<Bool?>
Creates a shared key that can read and write to an optional boolean user default.
static func appStorage(_ key: String, store: UserDefaults? = nil) -> Self where Self == AppStorageKey<Double>
Creates a shared key that can read and write to a double user default.
static func appStorage(_ key: String, store: UserDefaults? = nil) -> Self where Self == AppStorageKey<Double?>
Creates a shared key that can read and write to an optional double user default.
static func appStorage(_ key: String, store: UserDefaults? = nil) -> Self where Self == AppStorageKey<Int>
Creates a shared key that can read and write to an integer user default.
static func appStorage(_ key: String, store: UserDefaults? = nil) -> Self where Self == AppStorageKey<Int?>
Creates a shared key that can read and write to an optional integer user default.
static func appStorage<Value>(_ key: String, store: UserDefaults? = nil) -> Self where Self == AppStorageKey<Value>, Value : RawRepresentable, Value : Sendable, Value.RawValue == String
Creates a shared key that can read and write to a string user default, transforming that to a RawRepresentable
data type.
static func appStorage<Value>(_ key: String, store: UserDefaults? = nil) -> Self where Self == AppStorageKey<Value>, Value : RawRepresentable, Value : Sendable, Value.RawValue == Int
Creates a shared key that can read and write to an integer user default, transforming that to a RawRepresentable
data type.
static func appStorage<Value>(_ key: String, store: UserDefaults? = nil) -> Self where Self == AppStorageKey<Value?>, Value : RawRepresentable, Value : Sendable, Value.RawValue == String
Creates a shared key that can read and write to an optional string user default, transforming that to a RawRepresentable
data type.
static func appStorage<Value>(_ key: String, store: UserDefaults? = nil) -> Self where Self == AppStorageKey<Value?>, Value : RawRepresentable, Value : Sendable, Value.RawValue == Int
Creates a shared key that can read and write to an optional integer user default, transforming that to a RawRepresentable
data type.
static func fileStorage<Value>(_ url: URL, decode: @escaping (Data) throws -> Value, encode: @escaping (Value) throws -> Data) -> Self where Self == FileStorageKey<Value>, Value : Sendable
Creates a shared key that can read and write to a value in the file system.
static func fileStorage<Value>(_ url: URL, decoder: JSONDecoder? = nil, encoder: JSONEncoder? = nil) -> Self where Self == FileStorageKey<Value>, Value : Decodable, Value : Encodable, Value : Sendable
Creates a shared key that can read and write to a Codable
value in the file system.
static func inMemory<Value>(_ key: String) -> Self where Self == InMemoryKey<Value>, Value : Sendable
Creates a shared key for sharing data in-memory for the lifetime of an application.
typealias Default = _SharedKeyDefault<Self>
Provides a default value to a shared key.