⚙️ A tiny property wrapper for UserDefaults. Only 60 lines of code.
import Persistent
extension UserDefaults {
// Optional property
@Persistent("login", .standard)
static var login: String?
// Property with default value
@Persistent("isDarkMode", false)
static var isDarkMode: Bool
}
UserDefaults.login = "mezhevikin"
UserDefaults.isDarkMode = true
let subscription = UserDefaults.$isDarkMode.sink {
print($0)
}
UserDefaults.isDarkMode = true
https://github.com/mezhevikin/persistent.git
Inspired Antonie Van Der Lee