CocoaPods trunk is moving to be read-only. Read more on the blog, there are 19 months to go.
TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Nov 2016 |
Maintained by Zero_Lee.
ZObjcStore是一个轻量级的对象存储框架。
假如你的项目当中有很多的零散信息需要持久化,数据量少,但是分散。还不至于使用数据库这种庞大的存储框架的时候,ZObjcStore也许非常适合你
在podfile中添加ZObjcStore依赖
pod 'ZObjcStore', '~> 1.0.1'
然后运行pod 更新
$ pod install
导入头文件
#import <ZObjcStore/ZCodingSupport.h> #import <ZObjcStore/ZObjcStore.h>
注意: 存储的Model类一定要继承
ZCodingSupport
。
@interface Student : ZCodingSupport
@property (nonatomic, strong) NSString *name;
@property (nonatomic, assign) int age;
@end
//更新用户名
+ (void)updateStudentName:(NSString *)name {
[ZObjcStore update:[Student class] value:name key:@"name"];
}
+ (NSString *)studentName {
return [ZObjcStore get:[Student class] key:@"name"];
}
我们上面已经存储量用户的相关信息,但是每个用户的信息是不一样的,App由`User_A`切换到了`User_B`账户,B账户肯定不需要A账户的存储信息,而且当`User_B`再切回`User_A`的时候,项目要保证A账户的信息还在。
这个时候,你可以考虑使用ZObjcStore的分管理用户存储功能
handleContext
, handleContext方法可以在不同管理用户间快速切换,但是注意,同一时间只能存在一个管理用户。
+ (void)handleContext:(NSString *)userId {
[ZObjcStore handleContext:userId];
}