NSDictionary *couponDataDic = recordData[@"data"];
NSMutableArray *allDataKeyArray = [NSMutableArray array];
NSMutableArray *allDataValueArray = [NSMutableArray array];
for (NSString *dataKey in [couponDataDic allKeys])
{
NSMutableArray *couponRecordArray = couponDataDic[dataKey];
NSDictionary *couponRecordDic = couponRecordArray.firstObject;
//value
if (![couponRecordDic isEqual:[NSNull null]])
{
CouponRecordModel *model = [[CouponRecordModel alloc] initWithJSONDic:couponRecordDic];
//detailList
if (![couponRecordDic[@"detailList"] isEqual:[NSNull null]])
{
for (id couponValue in couponRecordDic[@"detailList"])
{
SendCouponModel *couponModel = [[SendCouponModel alloc] initWithJSONDic:couponValue];
//coupon--title
if (![couponValue[@"coupon"] isEqual:[NSNull null]])
{
NSDictionary *couponTitleDic = couponValue[@"coupon"];
couponModel.title = couponTitleDic[@"title"];
}
[model.detailListArray addObject:couponValue];
}
}
//shopCustomer
if (![couponRecordDic[@"shopCustomer"] isEqual:[NSNull null]])
{
ShopCustomerModel *customerModel = [[ShopCustomerModel alloc] initWithJSONDic:couponRecordDic[@"shopCustomer"]];
model.shopCustomerModel = customerModel;
NSLog(@" model.shopCustomerModel.name%@",model.shopCustomerModel.name);
}
//key--理论上来说,只有值有效的时候才同时记录,确保两个数组的个数遗迹位置完全吻合
[allDataKeyArray addObject:dataKey];
//value
[allDataValueArray addObject:model];
}
}
[_couponRecordTV sendCouponRecord:allDataKeyArray andValue:allDataValueArray];
字典解析
最新推荐文章于 2024-02-24 19:25:21 发布