1.遍历字典
[dict enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
NSLog(@"key = %@, value = %@", key, obj);
}];
2.注意事项:
// 如果是不可变数组, 那么key不能相同
// 如果是不可变字典出现了同名的key, 那么后面的key对应的值不会被保存
// 如果是在可变数组中, 后面的会覆盖前面的
NSDictionary *dict = @{@"name":@"lmj", @"name":@"lnj"};
NSLog(@"dict = %@", dict);
NSMutableDictionary *dictM = [NSMutableDictionary dictionaryWithObjects:@[@"lmj", @"lnj"] forKeys:@[@"name", @"name"]];
NSLog(@"dict = %@", dictM);