DiskVar 0.2.0

DiskVar 0.2.0

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Mar 2016
SPMSupports SPM

Maintained by ‘Beeth0ven --description=‘Mac Mini.



DiskVar 0.2.0

  • By
  • Luo Jie

DiskVar

Provide a convenience method to access NSUserDefaults

Usage:

 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.

License

DiskVar is under MIT license. See the LICENSE file for more info.