数据解析
一个数组内包含字典,取字典里面的一项数据添加在新的数组内
-
情况1
NSDictionary *dic1 = @{@"1":@"one",@"2":@"two"};
NSDictionary *dic2 = @{@"1":@"one2",@"2":@"two2"};NSArray *array = @[dic1,dic2];
NSArray *valuearray = [array valueForKeyPath:@"1"];NSLog(@"%@",valuearray);
// 打印情况
2016-04-16 14:09:38.592 autoLayout[14403:208007] (
one,
one2
) -
情况2
NSMutableArray *BillingList = _model.r2_BillingList; _imgUrlArr =[NSMutableArray array]; _contentArr = [NSMutableArray array]; for (NSInteger i= 0; i<BillingList.count; i++) { ** 情况一取值 ** _imgUrlArr = [BillingList valueForKeyPath:@"url"]; _contentArr = [BillingList valueForKeyPath:@"content"]; **情况二取值** // NSString *urlStr =[[BillingList objectAtIndex:i] valueForKey:@"url"]; // [_imgUrlArr addObject:urlStr]; // NSString *contentStr =[[BillingList objectAtIndex:i] valueForKey:@"content"]; // [_contentArr addObject:contentStr]; }