Swiftpack.co - muukii/OneStore as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by muukii.
muukii/OneStore 1.1.3
📕A single value proxy for NSUserDefaults, with clean API.
⭐️ 27
🕓 2 years ago
iOS
.package(url: "https://github.com/muukii/OneStore.git", from: "1.1.3")

OneStore

CI Status Version License Platform Carthage compatible

A single value proxy for NSUserDefaults, with clean API.

With OneStore…

  • Create one proxy(an OneStore object) for each NSUserDefaults value.
  • Multiple NSUserDefaults and namespaces are supported with Stacks.

Example

Basic

let name = OneStore<String>("name")
let age = OneStore<Int>("age")

name.value = "muukii"
age.value = 18

Specify Stack

let stack = Stack(userDefaults: NSUserDefaults(suiteName: "group.me.muukii.Fil")!, namespace: "me")
let name = OneStore<String>("name", stack: stack)
let age = OneStore<Int>("age", stack: stack)

name.value = "muukii"
age.value = 18

Remove object

let name = OneStore<String>("name", stack: stack)
name.value = nil

Remove all objects on namespace


let stack = Stack(userDefaults: NSUserDefaults.standardUserDefaults(), namespace: "me")
let name = OneStore<String>("name", stack: stack)

stack.removeAllObjectsOnNamespace()
/* or */
name.stack.removeAllObjectsOnNamespace()

Realworld example


enum Me {

    static let name = OneStore<String>("name", stack: Me.stack)
    static let age = OneStore<Int>("age", stack: Me.stack)

    private static let stack = Stack(userDefaults: NSUserDefaults.standardUserDefaults(), namespace: "me")
}

Me.name.value = "muukii"

Requirements

Swift 3.0

Installation

OneStore is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "OneStore"

Author

muukii, [email protected]

License

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

GitHub

link
Stars: 27
Last commit: 2 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics