Skip to content
This repository has been archived by the owner on May 12, 2022. It is now read-only.
/ OneStore Public archive

📕A single value proxy for NSUserDefaults, with clean API.

License

Notifications You must be signed in to change notification settings

muukii/OneStore

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

68 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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, m@muukii.me

License

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