dictionary

1.字面量创建字典

NSDictionary *dic=@{@"1":@"2",@"3":@"4"};

NSLog(@"%@",dic);



2.可变字典

[dic setObject:@"7" forKey:@"8"];

 NSLog(@"%@",dic);

key不存在进行键值对的添加,存在进行值得修改

移除键值对

[dic removeObjectForKey:@"8"];

NSLog(@"%@",dic);

[dic removeAllObjects];

NSLog(@"%@",dic);

setobject是字典自己的方法,setValuekVC的方法,即使效果一样,但是以后要对字典进行操作,还是setObject


你可能感兴趣的:(dictionary)