//创建单个字典
NSDictionary *dic = [NSDictionary dictionaryWithObject:@"obj" forKey:@"key"];
//创建多个字典
NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:@"obj1", @"key1",@"obj2", @"key2",nil];
//根据已有字典创建新的字典
NSDictionary *dic1 = [NSDictionary dictionaryWithDictionary:dic];
//将从新分配的字典初始化为键-对象对
NSDictionary *dic = [[NSDictionary alloc] initWithObjectsAndKeys:@"obj1",@"key1",@"obj2",@"key2",nil];
//特殊语法创建
NSDictionary *dic = @{obj1,key1,obj2,key2,.......}; |
|