美文网首页
iOS--- 数组里面取字典的值

iOS--- 数组里面取字典的值

作者: 鑫飞 | 来源:发表于2017-07-04 10:23 被阅读741次
    NSArray *arrData = @[@"1",@"2",@"3",@"4"];
    NSArray *arrKey = @[@"A",@"B",@"C",@"D"];
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithObjects:arrData forKeys:arrKey];
                     
    NSArray *arrData1 = @[@"5",@"6",@"7",@"8"];
    NSArray *arrKey1 = @[@"E",@"F",@"G",@"H"];
    NSMutableDictionary *dic1 = [NSMutableDictionary dictionaryWithObjects:arrData1 forKeys:arrKey1];
    NSMutableArray *arr = [NSMutableArray arrayWithObjects:dic,dic1, nil];
                     
    for (int i=0; i<[arr count]; i++) {
        for (id f in [arr objectAtIndex:i]) {
            NSLog(@"value = %@",[[arr objectAtIndex:i] valueForKey:f]);
            NSLog(@"key = %@",f);
        }
    }
    NSLog(@"arr = %@",[arr description]);
    
    

    相关文章

      网友评论

          本文标题:iOS--- 数组里面取字典的值

          本文链接:https://www.haomeiwen.com/subject/yhwscxtx.html