当前位置:网站首页>OC-NSDictionary
OC-NSDictionary
2022-08-02 07:49:00 【Classmate Peng, she is at the same table】
#NSDictionary
初始化
//方法一
NSDictionary *dict = [[NSDictionary alloc]initWithObjectsAndKeys:@"value1",@"key1",@"value2",@"key2",nil];
NSLog(@"%@",dict);//Crashes if the number of key-value pairs does not match
//方法二 It can be initialized through an array
NSDictionary*dict2 = [NSDictionary dictionartWithObjects:@[@"value1",@"value2"] forKeys:@[@"key1",@"key2"]];
NSLog(@"%@",dict2);
NSDictionary*dict2 = @{
@"k1":@"v1",
@"k2":@"v2"};//注意这里 必须是先k再v
查
//直接通过key值获取val值
NSLog(@“%@”,dict3[@"k2"]);
//直接循环获取key值
for(NSString *string in dict3)
{
NSLog(@"%@ %@",string,dict3[string]);
}
//Get all directly with the arraykey值
NSArray* array = [dict3 allKeys];
NSLog(@"%@",array);// k1,k2
//Get all directly with the arraykey值
NSArray* array1 = [dict3 allValues];
NSLog(@"%@",array1);// v1,v2
NSMutableDictionary
初始化
NSMutableDictionary* dict = [NSMutableDictionary dictionary];
dict[@“k1”] = @“v1”;
边栏推荐
- “蔚来杯“2022牛客暑期多校训练营4,签到题NDKHL
- PWA 踩坑 - 第一次加载页面后无法获取CacheStorage某些资源
- OC-NSArray
- 请教一下,Flink SQL ,JDBC sink 入 mysql 库,想要搞一个自增主键,要怎么写
- SQL server 2014 怎么一次性导出多个查询结果?
- JS初识高阶函数和函数柯里化
- 飞桨paddle技术点整理
- Vscode connect to remote server "Acquiring the lock on the/home / ~ 'problem
- OC-Category
- 【机器学习】实验6布置:基于集成学习的Amazon用户评论质量预测
猜你喜欢

Gradle系列——Gradle插件(基于Gradle文档7.5)day3-2

图腾柱和推挽电路介绍

(2022牛客多校五)B-Watches(二分)

【图像去噪】基于matlab双立方插值和稀疏表示图像去噪【含Matlab源码 2009期】

论文阅读 (64):Weakly-supervised Video Anomaly Detection with Robust Temporal Feature Magnitude Learning

吃透Chisel语言.31.Chisel进阶之通信状态机(三)——Ready-Valid接口:定义、时序和Chisel中的实现

深度学习网络模型的改进与调整

反射课后习题及做题记录

在VMware上安装Metasploitable2

实验8 VLAN综合实验
随机推荐
FormData上传二进制文件、对象、对象数组
交换网络----三种生成树协议
【红队】ATT&CK - 创建或修改系统进程实现持久化(更新ing)
OC-NSNumber和NSValue一般用来装箱拆箱
optional
Link with Game Glitch(spfa判负环)
MySQL-FlinkCDC-Hudi实时入湖
Agile, DevOps and Embedded Systems Testing
Xilinx约束学习笔记—— 时序约束
暑假第五周总结
View port number occupancy
入门opencv,欢笑快乐每一天
OC-NSArray
About the SQL concat () function problem, how to splice
实验8 VLAN综合实验
实验7 MPLS实验
OC-NSNumber and NSValue are generally used for boxing and unboxing
新产品立大功 伟世通第二季度营收双增
Splunk Field Caculated 计算字段
OC-NSString