您的位置:首页 > 其它

字典解析

2016-03-30 16:38 295 查看
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];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: