CoreModel 1.0.0

CoreModel 1.0.0

Tests已测试
Lang语言 Obj-CObjective C
许可证 MIT
Released最后发布2017年3月

naftaly 维护。



CoreModel 1.0.0

CoreModel 是一个轻量级框架,简化了将数据转换为可用对象的过程。API 允许您快速获取数据并将其作为对象实例带入您的应用。

安装

CoreModel 可在 CocoaPods 上使用。只需将以下内容添加到您的项目 Podfile 中

pod 'CoreModel'

使用方法

首先使用以下导入语句引入它

#import <CoreModel/CoreModel.h>

从某处找到一些数据。让我们使用一些 JSON 数据作为示例,这是 CoreModel 默认处理的内容

{ "firstName": "Alex", "lastName": "Cohen", "profession": "Developer", "age": 37, "married": YES }

创建 CMModel 的一个子类,让我们称其为 Person

 @interface Person : CMModel

 @property (strong) NSString* firstName;
 @property (strong) NSString* lastName;
 @property (strong) NSString* gender;
 @property (strong) NSString* profession;
 @property (assign) NSUInteger age;
 @property (assign) BOOL married;

 @end

 @implementation Employee
 @end

然后简单地加载它

 Person* person = [[Person alloc] initWithData:data error:nil];

现在您有一个完全初始化的 person 实例,其中包含了您提供的数据。

许可证

CoreModel 基于 MIT 许可证发布。有关详细信息,请参阅 LICENSE 文件。