網(wǎng)絡(luò)請求后,由json轉(zhuǎn)model的過程有一個小問題
例如,json是這樣的
{
? ? "state":true,
? ? "total":1,
? ? "rows":[
? ? ? ? {
? ? ? ? ? ? "gdh":"CCCC",
? ? ? ? ? ? "wldm":"BBBB",
? ? ? ? ? ? "wlmc":"AAAA",
? ? ? ? ? ? "yqslsj":"2020-12-04 09:57:10:423",
? ? ? ? ? ? "yqslsl":1,
? ? ? ? ? ? "sjslsj":"2020-12-04 09:57:10:423",
? ? ? ? ? ? "sjslsl":3
? ? ? ? }
? ? ]
}
通過 https://app.quicktype.io/? 轉(zhuǎn)成model,
如圖

model
然后使用yymodel 或者MJExtend 轉(zhuǎn)化,
? ? ? ? workOrderResponse = [GBOrderListResponse yy_modelWithJSON:request.responseJSONObject];
你在使用的時候直接用response.rows[o].gdh,會報錯。
這個時候需要在.m文件中加上
+ (NSDictionary *)modelContainerPropertyGenericClass {
? // value使用[YYEatModel class]或YYEatModel.class或@"YYEatModel"沒有區(qū)別
? ? return @{@"rows" : [UpdateWorkOrderTimeRows class]};
}