Skip to content

PhanithNY/Store

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Store

A drop-in UserDefaults wrapper using @propertyWrapper.

Usage

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
}

Installation

Copy Store.swift to your project, or

Swift Package Manager

From Xcode menu bar:

  1. File
  2. Swift Packages
  3. Add Package Dependency...
  4. Paste the repo url https://github.com/PhanithNY/Store.git

Author

PhanithNY, [email protected]

About

A drop-in UserDefaults wrapper using @propertyWrapper.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages