ObjectUserDefaultsItem

@objc
public class ObjectUserDefaultsItem : NSObject

A class representing a value stored in UserDefaults or ObjectUserDefaults. The item can exist or not.

  • Undocumented

    Declaration

    Swift

    public override var description: String { get }
  • key

    The key of the object in UserDefaults.

    Declaration

    Swift

    @objc
    private(set) public var key: String
  • Returns or sets the object associated with the specified key.

    Declaration

    Swift

    @objc
    public var value: Any? { get set }

    Return Value

    The object associated with the specified key, or nil if the key was not found.

  • Returns or sets the URL associated with the specified key.

    Wraps UserDefaults.url(forKey:).

    Declaration

    Swift

    @objc
    public var urlValue: URL? { get set }

    Return Value

    The URL associated with the specified key. If the key doesn’t exist, this method returns nil.

  • Returns or sets the array associated with the specified key.

    Wraps UserDefaults.array(forKey:).

    Declaration

    Swift

    @objc
    public var arrayValue: [Any]? { get set }

    Return Value

    The array associated with the specified key, or nil if the key does not exist or its value is not an array.

  • Returns or sets the dictionary object associated with the specified key.

    Wraps UserDefaults.dictionary(forKey:).

    Declaration

    Swift

    @objc
    public var dictionaryValue: [String : Any]? { get set }

    Return Value

    The dictionary object associated with the specified key, or nil if the key does not exist or its value is not a dictionary.

  • Returns or sets the string associated with the specified key.

    Wraps UserDefaults.string(forKey:).

    Declaration

    Swift

    @objc
    public var stringValue: String? { get set }

    Return Value

    For string values, the string associated with the specified key; for number values, the string value of the number. Returns nil if the default does not exist or is not a string or number value.

  • Returns or sets the array of strings associated with the specified key.

    Wraps UserDefaults.stringArray(forKey:).

    Declaration

    Swift

    @objc
    public var stringArray: [String]? { get set }

    Return Value

    The array of string objects, or nil if the specified default does not exist, the default does not contain an array, or the array does not contain strings.

  • Returns or sets the data object associated with the specified key.

    Wraps UserDefaults.data(forKey:).

    Declaration

    Swift

    @objc
    public var dataValue: Data? { get set }

    Return Value

    The data object associated with the specified key, or nil if the key does not exist or its value is not a data object.

  • Returns or sets the Boolean value associated with the specified key.

    Wraps UserDefaults.bool(forKey:).

    Declaration

    Swift

    @objc
    public var boolValue: Bool { get set }

    Return Value

    The Boolean value associated with the specified key. If the specified key doesn‘t exist, this method returns false.

  • Returns or sets the integer value associated with the specified key.

    Wraps UserDefaults.integer(forKey:).

    Declaration

    Swift

    @objc
    public var integerValue: Int { get set }

    Return Value

    The integer value associated with the specified key. If the specified key doesn‘t exist, this method returns 0.

  • Returns or sets the float value associated with the specified key.

    Wraps UserDefaults.float(forKey:).

    Declaration

    Swift

    @objc
    public var floatValue: Float { get set }

    Return Value

    The float value associated with the specified key. If the key doesn‘t exist, this method returns 0.

  • Returns or sets the double value associated with the specified key.

    Wraps UserDefaults.double(forKey:).

    Declaration

    Swift

    @objc
    public var doubleValue: Double { get set }

    Return Value

    The double value associated with the specified key. If the key doesn‘t exist, this method returns 0.