UserDefaultsStorage
@StorageActor
open class UserDefaultsStorage : Storage
UserDefaultsStorage
subclass of UserDefaults
that uses a DelegatedStorage
.
-
UserDefaultsStorage
shared instance.Declaration
Swift
@StorageActor open class var standard: UserDefaultsStorage { get }
-
Create a
UserDefaultsStorage
.Declaration
Swift
@StorageActor public convenience init(authenticationTag: Data? = nil)
Parameters
authenticationTag
Custom additional
Data
to be authenticated. -
Create a
UserDefaultsStorage
.Declaration
Swift
@StorageActor public init?(suiteName suitename: String?, symmetricKey: SymmetricKey, authenticationTag: Data? = nil)
Parameters
suiteName
The domain identifier of the search list.
symmetricKey
A cryptographic key used to seal the message.
authenticationTag
Custom additional
Data
to be authenticated. -
Returns the
StorageData
associated with the specifiedStoreKey
.Declaration
Swift
@StorageActor open func data<D>(forKey key: StoreKey) -> D? where D : StorageData
Parameters
key
A
StoreKey
in storage. -
Sets the value of the specified
StoreKey
to the specifiedStorageData
.Declaration
Swift
@StorageActor open func set(_ data: (some StorageData)?, forKey defaultName: StoreKey)
Parameters
data
StorageData
to store.defaultName
The
StoreKey
with which to associate the value. -
Removes the value of the specified
StoreKey
.Declaration
Swift
@StorageActor open func remove(forKey key: StoreKey)
Parameters
key
The
StoreKey
whose value you want to remove. -
Adds the contents of the specified dictionary to the registration domain.
Declaration
Swift
@StorageActor open func register(defaults registrationDictionary: [StoreKey : Any])
Parameters
defaults
The dictionary of keys and values you want to register.
-
Returns the generic value associated with the specified
StoreKey
.Declaration
Swift
@StorageActor open func value<V>(forKey key: StoreKey) -> V?
Parameters
key
A
StoreKey
in storage. -
Returns the
Decodable
associated with the specifiedStoreKey
.Declaration
Swift
@StorageActor open func decodable<D>(forKey key: StoreKey) -> D? where D : Decodable
Parameters
key
A
StoreKey
in storage. -
Sets the value of the specified
StoreKey
to the specifiedString
.Declaration
Swift
@StorageActor open func set(_ string: String, forKey key: StoreKey)
Parameters
string
String
to store.key
The
StoreKey
with which to associate the value. -
Sets the value of the specified
StoreKey
to the specified generic value.Declaration
Swift
@StorageActor open func set(_ value: (some Any)?, forKey key: StoreKey)
Parameters
value
Generic value to store.
key
The
StoreKey
with which to associate the value. -
Sets the value of the specified
StoreKey
to the specifiedEncodable
.Declaration
Swift
@StorageActor open func set(encodable: Encodable?, forKey key: StoreKey)
Parameters
encodable
Encodable
to store.key
The
StoreKey
with which to associate the value. -
Returns the
String
associated with the specifiedStoreKey
.Declaration
Swift
@StorageActor open func string(forKey defaultName: StoreKey) -> String?
Parameters
defaultName
A
StoreKey
in storage. -
Returns the
[Any]
associated with the specifiedStoreKey
.Declaration
Swift
@StorageActor open func array(forKey defaultName: StoreKey) -> [Any]?
Parameters
defaultName
A
StoreKey
in storage. -
Returns the
Set<AnyHashable>
associated with the specifiedStoreKey
.Declaration
Swift
@StorageActor open func set(forKey defaultName: StoreKey) -> Set<AnyHashable>?
Parameters
defaultName
A
StoreKey
in storage. -
Returns the
[String: Any]
associated with the specifiedStoreKey
.Declaration
Swift
@StorageActor open func dictionary(forKey defaultName: StoreKey) -> [String : Any]?
Parameters
defaultName
A
StoreKey
in storage. -
Returns the
[String]
associated with the specifiedStoreKey
.Declaration
Swift
@StorageActor open func stringArray(forKey defaultName: StoreKey) -> [String]?
Parameters
defaultName
A
StoreKey
in storage. -
Returns the
Int
associated with the specifiedStoreKey
.Declaration
Swift
@StorageActor open func integer(forKey defaultName: StoreKey) -> Int
Parameters
defaultName
A
StoreKey
in storage. -
Returns the
Float
associated with the specifiedStoreKey
.Declaration
Swift
@StorageActor open func float(forKey defaultName: StoreKey) -> Float
Parameters
defaultName
A
StoreKey
in storage. -
Returns the
Double
associated with the specifiedStoreKey
.Declaration
Swift
@StorageActor open func double(forKey defaultName: StoreKey) -> Double
Parameters
defaultName
A
StoreKey
in storage. -
Returns the
Bool
associated with the specifiedStoreKey
.Declaration
Swift
@StorageActor open func bool(forKey defaultName: StoreKey) -> Bool
Parameters
defaultName
A
StoreKey
in storage. -
Returns the
URL
associated with the specifiedStoreKey
.Declaration
Swift
@StorageActor open func url(forKey defaultName: StoreKey) -> URL?
Parameters
defaultName
A
StoreKey
in storage. -
Sets the value of the specified
StoreKey
to the specifiedInt
.Declaration
Swift
@StorageActor open func set(_ value: Int, forKey defaultName: StoreKey)
Parameters
value
Int
to store.defaultName
The
StoreKey
with which to associate the value. -
Sets the value of the specified
StoreKey
to the specifiedFloat
.Declaration
Swift
@StorageActor open func set(_ value: Float, forKey defaultName: StoreKey)
Parameters
value
Float
to store.defaultName
The
StoreKey
with which to associate the value. -
Sets the value of the specified
StoreKey
to the specifiedDouble
.Declaration
Swift
@StorageActor open func set(_ value: Double, forKey defaultName: StoreKey)
Parameters
value
Double
to store.defaultName
The
StoreKey
with which to associate the value. -
Sets the value of the specified
StoreKey
to the specifiedBool
.Declaration
Swift
@StorageActor open func set(_ value: Bool, forKey defaultName: StoreKey)
Parameters
value
Bool
to store.defaultName
The
StoreKey
with which to associate the value. -
Sets the value of the specified
StoreKey
to the specifiedURL
.Declaration
Swift
@StorageActor open func set(_ url: URL?, forKey defaultName: StoreKey)
Parameters
url
URL
to store.defaultName
The
StoreKey
with which to associate the value.