NSDictionary*dic =@{@"8":@"AAAA",
@"2":@"BBBBB",
@"3":@"CCCCCC",
@"1":@"FFFFF"};
NSArray*arrKeys = [dicallKeys];
for(inti =0; i < arrKeys.count; i++)
{
NSString*key = arrKeys[i];
NSString*value = [dicvalueForKey:key];
NSLog(@"%@ = %@",key,value);
}
NSLog(@"%zd",dic.count);
// 2
[dicenumerateKeysAndObjectsUsingBlock:^(idkey,idobj,BOOL*stop) {
NSLog(@"key = %@ and obj = %@", key, obj);
}];
将一个字典键值添加到另外一个字典中 关键字 setVlue
NSDictionary*dict=@{@"1":@"1",@"2":@"2"};
NSMutableDictionary*myHeader=[[NSMutableDictionaryalloc]init];
[myHeader setValue:@"8"forKey:@"8"];
[myHeader setValue:@"9"forKey:@"9"];
[myHeader setValue:@"10"forKey:@"10"];
[myHeader addEntriesFromDictionary:dict];
可以将 dict 字典的键值对添加到 myHeader 中