NSDictionary *dic1=[NSDictionary dictionaryWithObjectsAndKeys: @"1",@"a",
@"2",@"b", @"3",@"c", @"2",@"d", nil];
//遍历1
//for (id key in dic1) {//注意对于字典for遍历循环的是key
// NSLog(@"%@=%@",key,[dic1 objectForKey:key]);
//}
/*结果: d=2
b=2 c=3 a=1 */
//遍历2
//NSEnumerator *enumerator=[dic1 keyEnumerator];//还有值的迭代器
//[dic1 objectEnumerator]
//id key=nil;
//while (key=[enumerator nextObject]) {
// NSLog(@"%@=%@",key,[dic1 objectForKey:key]);
//}
/*结果: d=2
b=2 c=3 a=1 */
//遍历3
[dic1 enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
NSLog(@"%@=%@",key,obj);
}];
/*结果: d=2
b=2 c=3 a=1 */