标签:
// ------------------------------字典-------------------------------------------------
NSDictionary *dic1 = [NSDictionary dictionaryWithObjectsAndKeys:@"111", @"one", @"222", @"two", @"333", @"three", nil];
NSLog(@"dic count=%ld", [dic1 count]);
for (id key in dic1)
{
NSLog(@"key=%@, value=%@", key, [dic1 objectForKey:key]);
}
// 可变字典
NSMutableDictionary *dic2 = [NSMutableDictionary dictionaryWithCapacity:1];
[dic2 setObject:@"111" forKey:@"one"];
[dic2 setObject:@"222" forKey:@"two"];
[dic2 setObject:@"333" forKey:@"three"];
[dic2 setObject:@"444" forKey:@"four"];
[dic2 setObject:@"555" forKey:@"five"];
NSLog(@"dic2=%@",dic2);
[dic2 removeObjectForKey:@"three"];
NSLog(@"dic2=%@",dic2);
NSLog(@"dic allkeys = %@", [dic2 allKeys]);
NSLog(@"dic allValues = %@", [dic2 allValues]);
标签:
原文地址:http://www.cnblogs.com/xiangjune/p/4883526.html