mirror of
https://github.com/metabolist/metatext.git
synced 2024-11-18 22:31:01 +00:00
24 lines
539 B
Swift
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) }
|
|
}
|
|
}
|