This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
// ----------------------------------------------------------------------------- | |
// Protocol | |
protocol UserDefaultsVariableProtocol { | |
associatedtype Value | |
var key: String { get } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
extension UserDefaults { | |
struct Key<Value> { | |
let name: String | |
init(_ name: String) { | |
self.name = name | |
} | |
} | |
subscript<V: Codable>(key: Key<V>) -> V? { |