metatext/Shared/Model/Defaults.swift
2020-08-05 23:45:57 -07:00

24 lines
539 B
Swift

// Copyright © 2020 Metabolist. All rights reserved.
import Foundation
class Defaults {
private let userDefaults: UserDefaults
init(userDefaults: UserDefaults) {
self.userDefaults = userDefaults
}
}
extension Defaults {
enum Item: String {
case recentIdentityID = "recent-identity-id"
}
}
extension Defaults {
subscript<T>(index: Defaults.Item) -> T? {
get { userDefaults.value(forKey: index.rawValue) as? T }
set { userDefaults.set(newValue, forKey: index.rawValue) }
}
}