Structures

The following structures are available globally.

  • Utility for saving to and restoring from UserDefaults.standard arbitrary structs

    Usage examples (given struct ProgLang: Codable):

    1. try to get setting value from AppDefaults if let val = AppDefaults.setting(for: prefLangKey) { // ok, can use the non-nil value }
    2. try to save a setting to AppDefaults if AppDefaults.set(prefLang, forKey: prefLangKey) { // ok, saved successfully }
    3. remove setting from AppDefaults

      AppDefaults<ProgLang>.remove(forKey: prefLangKey)
      
    See more

    Declaration

    Swift

    struct AppDefaults<Struct> where Struct : Decodable, Struct : Encodable
  • Packs two hashable items into a hashable struct, so that the struct can be used as a key in a dictionary

    See more

    Declaration

    Swift

    struct HashablePair<P1, P2> : Hashable where P1 : Hashable, P2 : Hashable