Latest 0.9.0
Homepage https://github.com/muukii/OneStore
License MIT
Platforms ios 8.0, watchos 2.0
Authors

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.

Latest podspec

{
    "name": "OneStore",
    "version": "0.9.0",
    "summary": "One value store proxy for NSUserDefaults",
    "homepage": "https://github.com/muukii/OneStore",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "muukii": "[email protected]"
    },
    "source": {
        "git": "https://github.com/muukii/OneStore.git",
        "tag": "0.9.0"
    },
    "social_media_url": "https://twitter.com/muukii0803",
    "platforms": {
        "ios": "8.0",
        "watchos": "2.0"
    },
    "source_files": "OneStore/**/*.swift",
    "pod_target_xcconfig": {
        "SWIFT_VERSION": "3.0"
    },
    "pushed_with_swift_version": "4"
}

Pin It on Pinterest

Share This