字典解析
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];
相关文章推荐
- Android studio 解决libpng warning: iCCP: Not recognizing known sRGB profile that has been edited
- 大型网站优化建议
- 新建target后info.plist的路径关联指向问题
- linux 文件权限
- jsp日期格式化标签<fmt>
- SpringMVC调用支付宝直充接口
- java通过JDBC链接SQLServer2012
- java redis 基本操作
- pyspider创建淘女郎图片爬虫任务-运行流程解析
- 网站统计中的数据收集原理及实现
- CSR8670的UART功能的应用笔记
- 哈哈...忽然就有了动力
- PHP.INI安全配置
- 排序方式
- android bitmap compress(图片压缩)
- java中的匿名内部类总结
- printf中几个不常用的格式说明
- hbase-default.xml file seems to be for an older version of HBase ,this version is 1.2.0
- 【甘道夫】HBase(0.96以上版本号)过滤器Filter具体解释及实例代码
- 基于谱减法的声音去噪