字典

//第一种创建字典,创建多个key-value

NSDictionary*dic=[NSDictionarydictionaryWithObjectsAndKeys:@"k1",@"v1"

,@"k2",@"v2",@"k3",@"v3",nil];

//NSLog(@"%@",dic);

//第二种创建字典创建一对key-value

NSDictionary*dic1=[NSDictionarydictionaryWithObject:@"VV"forKey:@"KK"];

//  NSLog(@"%@",dic1);

//第三种创建多对间值

NSArray*key=[NSArrayarrayWithObjects:@"K1",@"K2",@"K3",nil];

NSArray*value=[NSArrayarrayWithObjects:@"V1",@"V2",@"V3",nil];

NSDictionary*dic2=[NSDictionarydictionaryWithObjects:key forKeys:value];

//NSLog(@"%@",dic2);

NSDictionary*dic3=[NSDictionarydictionaryWithDictionary:dic2];

NSLog(@"%@",dic3);

你可能感兴趣的:(字典)