TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Jan 2017 |
Maintained by Silence0201.
将JSON快速转换模型
将项目目录下的SIModel
导入项目中
导入头文件
#import "NSObject+SIModel.h"
建立模型对象,进行属性定义(仅支持默认get和set方法)
如果Array
中包含自定义Class
,需要实现:
+ (NSDictionary <NSString *,Class> *)si_clazzInArray{
return @{@"users":[User class]} ;
}
如何属性名和JSON或字典中的key不相同,需要实现:
+ (NSDictionary <NSString *,NSString *> *)si_replaceKeyFromPropertyName{
return @{
@"ID" : @"id" ,
@"desc" : @"desciption"
} ;
}
过程处理
+ (void)si_beginObjectToModel:(id)obj{
NSLog(@"开始转换:%@",obj) ;
}
+ (void)si_endObjectToModel:(id)model{
NSLog(@"结束转换:%@",model) ;
}
快速归档
@interface Members : NSObject<NSCoding>
// 实现中添加
SIModelCodingImplementation
更多请查看NSObject+SIModel.h
说明
SIModel is available under the MIT license. See the LICENSE file for more info.