//創建可變字典
NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"one", @"1", @"two",@"2",@"three",@"3", nil];
NSMutableDictionary *dict2 = [[NSMutableDictionary alloc]init];
NSMutableDictionary *dict3 = @{@"1":@"one",@"2":@"two",@"3":@"three"};
//添加鍵值對(如果這個鍵存在,那就是修改該值)
[dict setObject:@"four" forKey:@"4"];
NSLog(@"dict = %@", dict);
//輸出 : dict = {1 = one;2 = two;3 = three;4 = four;}
//刪除鍵值對
[dict removeObjectForKey:@"4"];
NSLog(@"dict = %@", dict);
//輸出 : dict = {1 = one;2 = two;3 = three;}
//刪除多個鍵值對
[dict removeObjectsForKeys:@[@"1",@"2"]];
NSLog(@"dict = %@",dict);
//輸出 : dict = {3 = three;}
//刪除所有鍵值對
[dict removeAllObjects];
NSLog(@"dict = %@", dict);
//把字典dict3中的鍵值對添加到dict中
[dict setDictionary:dict3];
NSLog(@"dict = %@", dict);
//輸出 : dict = {1 = one;2 =two;3 = three;}