LITLightweightStore 0.1.2

LITLightweightStore 0.1.2

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
版本最后发布2018年8月

Dmitry Lobanov 维护。



  • 作者
  • Dmitry Lobanov

LITLightweightStore

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

这是一个轻量级的键值存储,如果您在应用程序中有几个设置并且不知道它们应该放在哪里,那么它可能非常有用。

##需求iOS 7或更高版本

##特性

  • 易于使用
  • 方便的设置

###实现了哪些功能?

  • 内存字典存储
  • 默认存储
  • 密钥链存储(包含 UICKeyChainStore
  • 策略切换(在存储间移动数据)

用法

要运行示例项目,请克隆仓库,然后首先从示例目录运行 pod install

需求

安装

LITLightweightStore可通过CocoaPods进行安装。只需将以下行添加到您的Podfile文件中即可。

pod "LITLightweightStore"

###导入

将库导入到项目中,只需添加

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

###示例

存储设备ID

假设,您有敏感数据或设置。假设,您需要自己生成的设备ID或您需要 isFirstUserInstall选项。

让我们看看示例

# 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];

清理

[store tearDown]; // cleanup store

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

切换策略

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

作者

Lobanov Dmitry, [email protected]

许可证

LITLightweightStore遵循MIT许可证。更多信息请参阅LICENSE文件。