LITLightweightStore 0.1.2

LITLightweightStore 0.1.2

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Aug 2018

Maintained by Dmitry Lobanov.



  • By
  • Dmitry Lobanov

LITLightweightStore

[![CI Status](http://img.shields.io/travis/Lobanov Dmitry/LITLightweightStore.svg?style=flat)](https://travis-ci.org/Lobanov Dmitry/LITLightweightStore) Version License Platform

This is a lightweight key-value store which could be useful if you have several settings in app and you don't know where you should place them

##Requirements iOS 7 or later

##Features

  • Easy to use
  • Convenience setup

###What implemented?

  • in-Memory dictionary store
  • Defaults store
  • Keychain store ( UICKeyChainStore inside )
  • Policy switching (move your data between stores)

Usage

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

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

pod "LITLightweightStore"

###Import

Import store into your project, just add

#import<LITLightweightStore/LITLightweightStore.h>
// or
@import LITLightweightStore;

###Examples

Storing device Id

Suppose, that you have sensitive data or settings. Suppose, that you need a device id that you generated by yourself or you need first-user-install option.

Let's see example:

# put device id 
NSString *deviceId = @"deviceId"; // please, use not so obvious name, of course.

// setup store in memory
LITLightweightStore *store = 
[LITLightweightStore storeWithPolicy:LITLightweightStorePolicyMemory options:@{LITLightweightStoreOptionsStoreScopeNameKey: @"app_settings", LITLightweightStoreOptionsAllFieldsArrayKey: deviceId}];

[store setField:deviceId byValue:@"YOUR_DEVICE_ID"];

// and if you go to release:
[store switchPolicy:LITLightweightStorePolicyDefaults];

// or more long-live:
[store switchPolicy:LITLightweightStorePolicyKeychain];

Cleanup

[store tearDown]; // cleanup store

[store setField:deviceId byValue:nil]; // cleanup value for field +deviceId+

Switch policy

LITLightweightStore *newStore = [store switchPolicy:LITLightweightStorePolicyDefaults];
LITLightweightStore *newStore = [store switchPolicy:LITLightweightStorePolicyKeychain];

Author

Lobanov Dmitry, [email protected]

License

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