yymodel 简单用法

2018-08-13  本文已影响173人  陆壹吱吱

早就听说YYmodel很腻害了,今天学习了一下,不多逼逼直接写上代码

(一)假如你的返回的数据类型是字典里套数组数组里面装字典的

[{"name","Mary"},{name:"Joe"}]

+ (nullableNSArray*)yy_modelArrayWithClass:(Class)cls json:(id)json

NSArray  * arr2 =  [NSArray yy_modelArrayWithClass:[BlackLogListModel class] json:[dic objectForKey:@"results"]];

(二)假如你是直接返回字典的

{  "size" : 2,  "results" :    {   "processBelong" : "2",    "processId" : 66    }}

+ (nullableinstancetype)yy_modelWithJSON:(id)json;

+ (nullableinstancetype)yy_modelWithDictionary:(NSDictionary*)dictionary;

 _model = [SafeMassDetaileModel yy_modelWithJSON:[dic objectForKey:@"results"]];

  _model  = [SafeMassDetaileModel yy_modelWithDictionary:[dic objectForKey:@"results"]];

上一篇 下一篇

猜你喜欢

热点阅读