Structures
The following structures are available globally.
-
Utility for saving to and restoring from UserDefaults.standard arbitrary structs
Usage examples (given struct ProgLang: Codable):
- try to get setting value from AppDefaults
if let val = AppDefaults
.setting(for: prefLangKey) { // ok, can use the non-nil value } - try to save a setting to AppDefaults if AppDefaults.set(prefLang, forKey: prefLangKey) { // ok, saved successfully }
remove setting from AppDefaults
AppDefaults<ProgLang>.remove(forKey: prefLangKey)
Declaration
Swift
struct AppDefaults<Struct> where Struct : Decodable, Struct : Encodable - try to get setting value from AppDefaults
if let val = AppDefaults
-
Packs two hashable items into a hashable struct, so that the struct can be used as a key in a dictionary
See moreDeclaration
Swift
struct HashablePair<P1, P2> : Hashable where P1 : Hashable, P2 : Hashable
Structures Reference