早就听说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"]];
网友评论