A drop-in UserDefaults wrapper using @propertyWrapper.
With Store, you can turn this:
final class Storage {
static let `default` = Storage()
var launchCount: Int {
get {
return UserDefaults.standard.integer(forKey: "launchCount")
}
set {
UserDefaults.standard.setValue(newValue, forKey: "launchCount")
}
}
}
to this:
final class Storage {
static let `default` = Storage()
@Store(key: "launchCount", defaultValue: 1)
var launchCount: Int
}
Copy Store.swift
to your project, or
From Xcode menu bar:
- File
- Swift Packages
- Add Package Dependency...
- Paste the repo url
https://github.com/PhanithNY/Store.git
PhanithNY, [email protected]