UserDefaults
class UserDefaults : NSObject
-
Returns the names of the
UserDefaults
keys for which values currently exist. Keys that are not strings are ignored.Declaration
Swift
public var settingNames: [String]
Return Value
The application settings names.
-
Returns the value associated with the given
UserDefaults
key.Declaration
Swift
public func value(named name: String) -> Any?
Parameters
name
The name of the setting whose value is to be retrieved.
Return Value
The value of the setting, or
nil
if no such setting exists.
-
Changes the value of the given setting to the specified object.
Declaration
Swift
public func set(value: Any, named name: String)
Parameters
value
The new value for the setting.
name
The name of the setting whose value is to be changed.
-
Removes the existing value (if any) for the setting with the given name.
Declaration
Swift
public func removeValue(named name: String)
Parameters
name
The name of the setting whose value is to be removed.