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

2017-07-04  本文已影响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]);

上一篇下一篇

猜你喜欢

热点阅读