UserDefaultsAdapter
Implementation of KeyValueStore
using UserDefaults
@objc public class UserDefaultsAdapter: NSObject, KeyValueStore
#
InheritanceKeyValueStore
, NSObject
#
Initializersinit(userDefaults:)
#
Creates a new UserDefaultsAdapter
with the given default.
@objc public init(userDefaults: UserDefaults)
#
Parameters- userDefaults:
UserDefaults
instance.
#
PropertiesuserDefaults
#
UserDefaults
used internally by this adapter.
@objc public let userDefaults: UserDefaults
#
Methodsobject(forKey:)
#
Returns the object associated with the specified key.
@objc public func object(forKey defaultName: String) -> Any?
#
Parameters- defaultName: A key in the current store.
bool(forKey:)
#
Returns the Boolean value associated with the specified key.
@objc public func bool(forKey defaultName: String) -> Bool
#
Parameters- defaultName: A key in the current store.
set(value:forKey:)
#
Sets the value of the specified key.
@objc public func set(value: Any?, forKey defaultName: String)
#
Parameters- value: The object to store in the store.
- defaultName: The key with which to associate the value.
set(boolValue:forKey:)
#
Sets the value of the specified key to the specified Boolean value.
@objc public func set(boolValue: Bool, forKey defaultName: String)
#
Parameters- boolValue: The Boolean value to store.
- defaultName: The key with which to associate the value.
removeObject(forKey:)
#
Removes the value of the specified default key.
@objc public func removeObject(forKey defaultName: String)
#
Parameters- defaultName: The key whose value you want to remove.