LHModel的简单使用:
LHModel是一个JSON转model,model转JSON的工具类。
使用很多runtime的API。调用简单,真正能用到的只有两个方法。
Model* model = [Model lh_ModelWithDictionary:dic];
NSDictionary* valueDic = [model lh_ModelToDictionary];
测试代码如下:
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
NSDictionary* dic = @{ @"name":@"apple",@"age":@18,@"height":@"180",@"array":@[@"lilei",@"lusy",@190],@"dic":@{ @"name":@1},@"url":@"www.baidu.com",@"date":[NSDate date],@"data":[@"modeltojsonandjsontomodel" dataUsingEncoding:NSUTF8StringEncoding],@"c":@'c'};
Model* model = [Model lh_ModelWithDictionary:dic]; //字典转Model
NSDictionary* valueDic = [model lh_ModelToDictionary]; //Model转字典
NSLog(@"%@",valueDic);
}