谈一下addEntriesFromDictionary在字典中的用法:
- 废话不多说,先上代码:
NSMutableDictionary *dic1 = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"BMW",@"CarLogo",@"Red",@"CarColor", nil];
NSDictionary *dic2 = [NSDictionary dictionaryWithObjectsAndKeys:@"Xiaoming",@"name",@"28", @"age",nil];
[dic1 addEntriesFromDictionary:dic2];
NSLog(@"%@",dic1);
看打印结果:
- 一目了然了吧。就是拼接字典用的。
- addEntriesFromDictionary是NSMutableDictionary的一个方法。