当前仓库属于关闭状态,部分功能使用受限,详情请查阅 仓库状态说明
1 Star 0 Fork 0

Dog / LYJArchiveModel
关闭

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

LYJArchiveModel

CI Status Version License Platform

Example

To run the example project, clone the repo, and run pod install or 'pod update' from the Example directory first. 1: 创建一个继承LYJArchiveModel的类UserModel,UserModel放入我们的使用的属性(支持的格式NSString, NSInteger, double, NSDictionary, NSArray, NSMutableDictionary, NSMutableArray, CGFloat, NSData, 继承LYJArchiveModel的类 , UIImage) 2: 在 UserModel 创建你自己使用到的属性 例如: #import "ArciveModel.h"

@class SubUserModel , UIImage;
@interface UserModel : ArciveModel

@property (nonatomic , copy) NSString *name;
@property (nonatomic , assign) BOOL isFirstLogin;
@property (nonatomic , assign) NSInteger age;
@property (nonatomic , assign) double height;
@property (nonatomic , strong) NSDictionary *dic;
@property (nonatomic , strong) NSArray *arr;
@property (nonatomic , strong) SubUserModel *subUserModel; // 继承LYJArchiveModel的子类
@property (nonatomic , strong) UIImage *userImage;
@end
3: 使用方法
在控制器中引入头文件: #import <LYJArchiveModel/LYJArchiveModel-umbrella.h>

UserModel *model = [UserModel new];
model.name = @"你好";
model.isFirstLogin = YES;
model.age = 18;
model.height = 181.5;
model.dic = @{@"1" : @"2"};
model.arr = @[@"4" , @"5"];
model.userImage = [UIImage imageNamed:@"123"];
model.subUserModel = [SubUserModel new];
model.subUserModel.name = @"你浪开";
model.subUserModel.age = 20;
model.subUserModel.isFirstLogin = YES;
model.subUserModel.height = 170.1;

// 如果归档时间较长,这里开启加载动画
if ([UserModel archive:model keyName:@"li"]) { // 这里开始归档并存储到本地,如果存储成功继续往下执行

    model = nil; // 这里置空,为了演示使用>
    // 储存完成后
    // 这里关闭加载动画
}

NSLog(@"Model name is %@" , model.name);

UserModel *newModel = [UserModel unarchiveWithKeyName:@"li"]; // 取出本地存储的数据,并进行解档
if (newModel.isFirstLogin) {

    NSLog(@"model.name is %@" , newModel.name);
    NSLog(@"%ld", newModel.age);
    NSLog(@"%.2f" , newModel.height);
    NSLog(@"dic is %@" , newModel.dic);
    self.photoImageView.image = newModel.userImage;
}

if (newModel.subUserModel.isFirstLogin) {

    NSLog(@"Info of subUserModel is %@ , %ld , %.2f" , newModel.subUserModel.name , newModel.subUserModel.age , newModel.subUserModel.height);
}

输出结果:
Model name is (null)
model.name is 你好
18
181.50
dic is {
1 = 2;
}
Info of subUserModel is 你浪开 , 20 , 170.10

Requirements

Installation

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

pod 'LYJArchiveModel'

Author

li625317534, 625317534@qq.com

License

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

Copyright (c) 2017 li625317534 <625317534@qq.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

创建一个NSObjec类,继承LYArchiveModel,可以实现模型的快速归档 展开 收起
Objective-C
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Objective-C
1
https://gitee.com/6253175234/LYJArchiveModel.git
git@gitee.com:6253175234/LYJArchiveModel.git
6253175234
LYJArchiveModel
LYJArchiveModel
master

搜索帮助

14c37bed 8189591 565d56ea 8189591