当前位置:网站首页>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”;
边栏推荐
猜你喜欢

敏捷、DevOps和嵌入式系统测试
![带手续费买卖股票的最大利益[找DP的状态定义到底缺什么?]](/img/14/cd6ed7452230571db2e027f61dbdba.png)
带手续费买卖股票的最大利益[找DP的状态定义到底缺什么?]

结构体大小计算--结构体内存对齐

论文《Deep Multifaceted Transformers for Multi-objective Ranking in Large-Scale E-commerce Recommender》

新产品立大功 伟世通第二季度营收双增
![(Part of it is not understood, and the notes are not completed) [Graph Theory] Difference Constraints](/img/e0/385579fc8657db8b175318bd739908.gif)
(Part of it is not understood, and the notes are not completed) [Graph Theory] Difference Constraints

【心电信号】基于matlab心率检测【含Matlab源码 1993期】

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

Agile, DevOps and Embedded Systems Testing

实例029:反向输出
随机推荐
初探形式化方法基本原理
Go implements distributed locks
以训辅教,以战促学 | 新版攻防世界平台正式上线运营!
获取间隔的日期列表工具类
View port number occupancy
牛客编程题中——需要处理输入较大数的题目
yml字符串读取时转成数字了怎么解决
【机器学习】实验3布置:贝叶斯垃圾邮件识别
regular expression
Gradle系列——Gradle插件(基于Gradle文档7.5)day3-2
查看僵尸进程
【图像去噪】基于matlab双立方插值和稀疏表示图像去噪【含Matlab源码 2009期】
修改apt-get源为国内镜像源
【图像隐藏】基于matlab混合DWT-HD-SVD数字图像水印方法技术【含Matlab源码 2007期】
实例027:递归输出
OC-NSArray
“蔚来杯“2022牛客暑期多校训练营4,签到题NDKHL
OC-NSArray
SimpleChannelInboundHandler使用总结
主流定时任务解决方案全横评