UserDefaults
class UserDefaults : NSObject
-
Mechanica
Returns
true
ifkey
exists.Declaration
Swift
public final func hasKey(_ key: String) -> Bool
-
Mechanica
Declaration
Swift
public final func optionalBool(forKey defaultName: String) -> Bool?
Parameters
defaultName
A key in the current user’s defaults database.
Return Value
The bool value associated with the specified key. If the specified key does not exist, this method returns nil.
-
Mechanica
Declaration
Swift
public final func optionalDouble(forKey defaultName: String) -> Double?
Parameters
defaultName
A key in the current user’s defaults database.
Return Value
The double value associated with the specified key. If the specified key does not exist, this method returns nil.
-
Mechanica
Declaration
Swift
public final func optionalFloat(forKey defaultName: String) -> Float?
Parameters
defaultName
A key in the current user’s defaults database.
Return Value
The floating-point value associated with the specified key. If the key does not exist, this method returns nil.
-
Mechanica
Declaration
Swift
public final func optionalInteger(forKey defaultName: String) -> Int?
Parameters
defaultName
A key in the current user’s defaults database.
Return Value
The integer value associated with the specified key. If the specified key does not exist, this method returns nil.
-
Mechanica
Removes all keys and values from user defaults.
Note
This method only removes keys on the receiverUserDefaults
object. System-defined keys will still be present afterwards.resetStandardUserDefaults
simply resets the in-memory user defaults object.Declaration
Swift
public final func removeAll()