ObjectUserDefaults
@objc
public class ObjectUserDefaults : NSObject
An object oriented wrapper UserDefaults
. Initialize it like an UserDefaults
. See ObjectUserDefaults.item(forKey:)
for getting and setting values.
-
The standard object for
UserDefaults.standard
Declaration
Swift
@objc public static let standard: ObjectUserDefaults
-
The
UserDefaults
instance associated with this object.Declaration
Swift
@objc private(set) public var userDefaults: UserDefaults
-
Initialize for
UserDefaults.standard
.Declaration
Swift
@objc public override init()
Return Value
-
Initialize
UserDefaults
with given suite name.Declaration
Swift
@objc public init?(suiteName: String? = nil)
Parameters
suiteName
The suite name passed to
UserDefaults(suiteName:)
.Return Value
An
ObjectUserDefaults
to be used with theUserDefaults
initialized with given suite name. IfsuiteName
isnil
, it will returnObjectUserDefaults.standard
-
Use this method to get a representation of the item for the given key.
Declaration
Swift
@objc public func item(forKey key: String) -> ObjectUserDefaultsItem
Parameters
key
Key used to set and get values.
Return Value
A representation of the item for the given key. See
ObjectUserDefaultsItem
to set and get values. -
Returns all items stored.
Declaration
Swift
@objc public var arrayRepresentation: [ObjectUserDefaultsItem] { get }