YaroslavZhurbilo
10/11/2017 - 8:37 AM

DefaultsKit

Simple, Strongly Typed UserDefaults for iOS, macOS and tvOS https://github.com/nmdias/DefaultsKit

enum Pet: String, Codable {
    case cat
    case dog
}

struct Person: Codable {
    let name: String
    let pets: [Pet]
}

// Get a Codable conforming instante
let person = Person(name: "Claire", pets: [.cat])

// Set the value
defaults.set(person, for: key)

// And read it back
let person = defaults.get(for: key)
person?.name        // Claire
person?.pets.first  // cat