TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Mar 2016 |
SPMSupports SPM | ✗ |
Maintained by ‘Beeth0ven --description=‘Mac Mini.
Provide a convenience method to access NSUserDefaults
class ViewController: UIViewController {
private var history = DiskVar<[String]>(key: "ViewController.history", defaultValue: ["cat"])
override func viewDidLoad() {
super.viewDidLoad()
// get
print(history.value) // ["cat"]
// set
history.value.append("dog") // ["cat", "dog"]
}
}
ViewController’s Property “history” is a Array of String which has a defaultValue of [“cat”]. “ViewController.history” is the key used in NSUserDefaults which should be unique in the project. And the history’s value will not be lost even if the app is closed.
DiskVar is under MIT license. See the LICENSE file for more info.