NSDictionary

// ------------------------------字典-------------------------------------------------

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]);

上一篇:将 Python3 文件打包成 exe 文件


下一篇:MyEclipse创建Web项目入门指南