字典

2017-02-23  本文已影响0人  我是世界微小的存在

//第一种创建字典,创建多个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);

上一篇下一篇

猜你喜欢

热点阅读