šŸ“•A single value proxy for NSUserDefaults, with clean API.

Overview

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.

You might also like...
An efficient, small mobile key-value storage framework developed by WeChat. Works on Android, iOS, macOS, Windows, and POSIX.
An efficient, small mobile key-value storage framework developed by WeChat. Works on Android, iOS, macOS, Windows, and POSIX.

äø­ę–‡ē‰ˆęœ¬čƷ参ēœ‹čæ™é‡Œ MMKV is an efficient, small, easy-to-use mobile key-value storage framework used in the WeChat application. It's currently available on Andr

An elegant, fast, thread-safe, multipurpose key-value storage, compatible with all Apple platforms.
An elegant, fast, thread-safe, multipurpose key-value storage, compatible with all Apple platforms.

KeyValueStorage An elegant, fast, thread-safe, multipurpose key-value storage, compatible with all Apple platforms. Supported Platforms iOS macOS watc

Typed key-value storage solution to store Codable types in various persistence layers with few lines of code!
Typed key-value storage solution to store Codable types in various persistence layers with few lines of code!

šŸ—‚ Stores A typed key-value storage solution to store Codable types in various persistence layers like User Defaults, File System, Core Data, Keychain

KeyPathKit is a library that provides the standard functions to manipulate data along with a call-syntax that relies on typed keypaths to make the call sites as short and clean as possible.

KeyPathKit Context Swift 4 has introduced a new type called KeyPath, with allows to access the properties of an object with a very nice syntax. For in

CleanArchitecture - Helping project to learn Clean Architecture using iOS (Swift)

Clean Architecture Helping project to learn Clean Architecture using iOS (Swift)

Sample implementation of HDMI Clean out for iPhone or iPad video output.
Sample implementation of HDMI Clean out for iPhone or iPad video output.

HDMIPassThroughSample Sample implementation of HDMI Clean out for iPhone or iPad video output. "Lightning - Digital AV Adapter" can be used to output

A basic application that fetches crypto coin datas from CoinBase API.

HW5_ErincDokumacioglu App named Investor that fetches latest exchange rates for cryptocurrencies from CoinMarketCap Currently has some issues, mainly

BucketServer - Small API with SQLite database that saves notes for an iOS appliction called Bucket list

BucketList Server-Side Small API with SQLite database that saves notes for an iO

Comments
  • Do OneStore support to store an array of values to UserDefaults?

    Do OneStore support to store an array of values to UserDefaults?

    @muukii, ## Do OneStore support to store an array of values to UserDefaults?

    For example, if we need to store array, [5, 6, 8], then can we directly do below?

    let storableIntArray = OneStore<[Int]>(...)
    storableIntArray.value = [5, 6, 8]
    
    opened by nitesh-technobrave 0
  • Setting value = nil, not removing key value from User Defaults; Not updating value to nil.

    Setting value = nil, not removing key value from User Defaults; Not updating value to nil.

    When I am setting "nil" value to OneStore property and then fetching it's value, getting old value instead of "nil".

    I think it is happening due to optional value is not unwrapped and handled for nil values.

    I have handled it for nil value. You can check latest code on left side.

    screen shot 2017-05-04 at 3 07 49 pm

    opened by niteshborad 2
  • Manual Installation

    Manual Installation

    CocoaPods and Carthage are awesome tools and make our life really easier, but there are some devs who still don't know how to use them.

    It would be cool to add the Manual installation guide in your README.md. You can take a look at my iOS Readme Template to see how you can do it.

    opened by lfarah 0
Releases(1.1.3)
Owner
Muukii
Swift & iOS - Working on creating apps and open-sourced libraries. I'm interested in Creating smooth and fancy UI, State-Management, Image Processing.
Muukii
Modern Swift API for NSUserDefaults

SwiftyUserDefaults Modern Swift API for NSUserDefaults SwiftyUserDefaults makes user defaults enjoyable to use by combining expressive Swifty API with

Luke 4.7k Jan 9, 2023
TypedDefaults is a utility library to type-safely use NSUserDefaults.

TypedDefaults TypedDefaults is a utility library to type-safely use NSUserDefaults. Motivation The talk Keep Calm and Type Erase On by Gwendolyn Westo

Kazunobu Tasaka 110 Feb 6, 2022
A lightweight wrapper over UserDefaults/NSUserDefaults with an additional layer of AES-256 encryption

SecureDefaults for iOS, macOS Requirements ā€¢ Usage ā€¢ Installation ā€¢ Contributing ā€¢ Acknowledgments ā€¢ Contributing ā€¢ Author ā€¢ License SecureDefaults is

Victor Peschenkov 216 Dec 22, 2022
Save NSObject into NSUserDefaults in one-line, auto class mapping

Akaibu What is it ? Archive any class in just ONE-LINE of code. Automatically map class's properties under the hood. Drop in replacement of NSObject S

Roy Tang 16 Jun 21, 2021
NSUserDefaults with Wings!

#Palau: NSUserDefaults with Wings! Features | Included Types | Installation | Validators and Defaults | Custom Types | DidSet Callback | ------- Featu

symentis GmbH 387 Jun 29, 2022
YapDB is a collection/key/value store with a plugin architecture. It's built atop sqlite, for Swift & objective-c developers.

YapDatabase is a collection/key/value store and so much more. It's built atop sqlite, for Swift & Objective-C developers, targeting macOS, iOS, tvOS &

Yap Studios 3.3k Dec 29, 2022
šŸ’¾ Safe, statically-typed, store-agnostic key-value storage written in Swift!

Storez ?? Safe, statically-typed, store-agnostic key-value storage Highlights Fully Customizable: Customize the persistence store, the KeyType class,

Kitz 67 Aug 7, 2022
An Objective-C wrapper for RocksDB - A Persistent Key-Value Store for Flash and RAM Storage.

ObjectiveRocks ObjectiveRocks is an Objective-C wrapper of Facebook's RocksDB - A Persistent Key-Value Store for Flash and RAM Storage. Current RocksD

Iskandar Abudiab 56 Nov 5, 2022
Key-Value store for Swift backed by LevelDB

SwiftStore Key/Value store for Swift backed by LevelDB. Usage Create instances of store import SwiftStore // Create a store. let store = SwiftStore(s

Hemanta Sapkota 119 Dec 21, 2022
A protocol-centric, type and queue safe key-value workflow.

Light-weight, strict protocol-first styled PropertyKit helps you to easily and safely handle guaranteed values, keys or types on various situations of

gitmerge 12 Feb 26, 2021