NSDictionary、NSMutableDictionary的基本用法

深入解析NPN与PNP传感器驱动电路的设计逻辑与实战应用 本文深入解析NPN与PNP传感器驱动电路的设计逻辑与实战应用,详细对比两者的电流路径差异和电平变化特性。通过实际案例分享电路设计要点,包括上拉电阻选择、保护二极管配置等,并提供工业应用中的选型策略和常见故障排查指南,帮助工程师优化传感器系统集成。 阅读详情

1.不可变词典NSDictionary

字典初始化

NSNumber *numObj = [NSNumber numberWithInt:100];

以一个元素初始化

NSDictionary *dic = [NSDictionary dictionaryWithObject:numObj forKey:@"key"];

初始化两个元素

NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:numObj, @"valueKey", numObj2, @"value2",nil];

初始化新字典,新字典包含otherDic

NSDictionary *dic = [NSDictionary dictionaryWithDictionary:otherDic];

以文件内容初始化字典

NSDictionary *dic = [NSDictionary dictionaryWithContentsOfFile:path];


常用方法

获取字典数量

NSInteger count = [dic count];

通过key获取对应的value对象

NSObject *valueObj = [dic objectForKey:@"key"];

将字典的key转成枚举对象,用于遍历

NSEnumerator *enumerator = [dic keyEnumerator];

获取所有键的集合

NSArray *keys = [dic allKeys];

获取所有值的集合

NSArray *values = [dic allValues];


2.可变数组NSMutableDictionary

初始化一个空的可变字典

NSMutableDictionary *dic2 = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"v1",@"key1",@"v2",@"key2",nil];

NSDictionary *dic3 = [NSDictionary dictionaryWithObject:@"v3" forKey:@"key3"];

向字典2对象中添加整个字典对象3

[dic2 addEntriesFromDictionary:dic3];

向字典2对象中最佳一个新的key3和value3

[dic2 setValue:@"value3" forKey:@"key3"];

初始化一个空的可变字典

NSMutableDictionary *dic1 = [NSMutableDictionary dictionary];

将空字典1对象内容设置与字典2对象相同

[dic1 setDictionary:dic2];

将字典中key1对应的值删除

[dic1 removeObjectForKey@"key1"];

NSArray *array = [NSArray arrayWithObjects:@"key1", nil];

根据指定的数组(key)移除字典1的内容

[dic2 removeObjectsForKeys:array];

移除字典所有对象

[dic1 removeAllObjects];


遍历字典

快速枚举

for (id key in dic){

     id obj = [dic objectForKey:key];

     NSLog(@"%@", obj);

}

一般枚举

NSArray *keys = [dic allKeys];

inr length = [keys count];

for (int i = 0; i < length;i++){

     id key = [keys objectAtIndex:i];

     id obj = [dic objectForKey:key];

     NSLog(@"%@", obj);

}

通过枚举类型枚举

NSEnumerator *enumerator = [dic keyEnumerator];

id key = [enumerator nextObject];

while (key) {

        id obj = [dic objectForKey:key];

        NSLog(@"%@", obj);

        key = [enumerator nextObject];

}

多租户Saas架构设计分析(基础篇) 本篇先给大家介绍一下相关的概念和常见问题。 实践篇链接:https://blog.csdn.net/haponchang/article/details/104246317 SaaS简介 SaaS是Software-as-a-Service(软件即服务)的简称,“软件即服务”?是不是有点拗口?其实你就理解成为“按需租用别人提供的软件服务”就可以了,它是一种软件交付模式。... 阅读详情

相关推荐

单目视觉定位:深入解析PNP算法在机器人导航中的实战应用

本文深入解析了PNP算法在机器人单目视觉定位中的核心原理与实战应用。通过拆解坐标变换四步,详细阐述了如何从二维图像点反求相机三维位姿。文章结合OpenCV的solvePnP函数,提供了算法选择、参数调优及结果后处理的实用指南,并针对机器人导航中的特征匹配、尺度不确定性等挑战,给出了鲁棒性优化与实时性平衡的解决方案。

weixin_29083649的博客 425

字典NSDictionary与可变字典NSmutableDictionary的用法

1、NSDictionary不可变字典——&gt;子类NSMutableDictionary可变字典 :都是根据一个唯一的标示键来找到的对应的值。 字典 Key————&gt;value 索引————&gt;文字内容 字典内部存放的是键值对 2、字典NSDictionary的创建方式:(一旦初始化就不可再修改) (1)创建具有一个键值对的字典方法。 NSDictionary *dic=[NSD...

iteye_18817的博客 453

【GEE实战】Sen+MK趋势分析:从代码到地图,解锁植被变化时空密码

本文详细介绍了在Google Earth Engine(GEE)平台上使用Sen斜率估计和Mann-Kendall(MK)检验进行植被变化趋势分析的全流程。从遥感数据加载、Sen斜率计算到MK显著性检验,结合代码示例和实战经验,帮助读者掌握植被时空变化分析的实用技巧,为生态监测和环境保护提供数据支持。

weixin_42628688的博客 216

可变字典(NSMutableDictionary)简介

字典是一个无序的集合,也可称之为键值对。与数组不同的是字典可以通过特定的key快速查找到想要的值,而不用遍历字典。所以一个唯一的key只能对应一个值,而多个key可以对应同一个值。字典分为不可变字典(NSDictionary)和可变字典(NSMutableDictionary)。NSMutableDictionary继承自NSDictionary。自本篇文章只介绍NSMutableDictionary的一些简单用法。

zhaoName的博客 2477

DSP28335与Vofa+上位机通信实战:SCIb配置避坑指南(附完整代码)

本文提供DSP28335与Vofa+上位机通信的实战指南,重点解析SCIb模块配置的常见问题与解决方案。针对研旭开发板的硬件连接、波特率精确计算、FIFO高效使用以及FireWater协议封装进行了详细说明,并附有完整代码,帮助开发者快速实现实时数据可视化与波形分析,提升调试效率。

weixin_29172963的博客 154

2026年数据中心运行与管理专业人才培养基地建设方案(高职、数据中心运行与管理新专业、人才培养、专业代码:510310)

摘要: 为响应国家“东数西算”战略和数字经济需求,我校拟联合行业领军企业建设数据中心运行与管理人才培养基地。项目基于国家政策引导和产业快速发展背景,针对行业10万人才缺口,对标教育部新设专业标准(510310),分三阶段实施五年规划:专业奠基(2026-2028)、内涵深化(2028-2029)、辐射引领(2030-2031)。建设内容涵盖校企协同岗位能力分析、模块化课程开发(如网络管理、自动化运维等)、实训基地搭建及“课证融通”培养模式,重点培养基础设施、网络服务、运维托管三类岗位技能人才,目标建成区域性

啊碧根果的博客 1707

【OC】字典(NSDictionary与NSMutableDictionary)

用于保存具有映射关系的数据,故而,NSDictionary保存着两种数值,分别是建和值。注意key与value都可以是任意引用类型的数据,Map的key不允许重复。key与value之间存在着一一对应的关系,即通过指定的key,总是可以找到唯一的、确定的value。key与value之间的关系NSDictionary中包含一个allkeys方法,用于返回NSDictionary所有key组成的集合。

2301_79847748的博客 2220

告别复杂配置!用GuidosToolbox 3.0做MSPA景观格局分析,从安装到出图全记录

本文详细介绍了如何使用GuidosToolbox 3.0进行MSPA景观格局分析,从安装配置到出图全流程。涵盖环境准备、数据预处理、参数设置、结果解读及可视化技巧,帮助用户快速掌握这一生态安全评估工具。特别针对安装教程中的常见问题提供解决方案,提升分析效率。

weixin_29248313的博客 494

【OC】NSDictionary和NSMutableDictionary

OC : NSDictionary和NSMutableDictionary

cheng_lin0201的博客 566

Snort源代码编译 _ 采坑之旅(for Windows VS2015)

    系统环境:Windows7 sp1 x64     编译环境:VS2015 SP1     Snort版本:2.9.12     daq版本:2.0.6     Snort官网:https://www.snort.org/downloads#snort-downloads 背景     最近需要实现一个类似网络防火墙的产品,主要参考Snort源码,先花了点时间简单读了下网上比较流行的《...

magictong的专栏 8892

CRC校验查表法详解

CRC校验的查表法理解算法原理基础计算查表法原理及计算查表法中的表CRC校验中数据逆序CRC校验中的其它参数 算法原理 CRC(Cyclic Redundance Check)循环冗余校验,是基于某个多项式计算出一组校验码,用于核对数据传输过程中是否被更改或传输错误 基础计算 假设需要检验的数据 g :10100111,这串二进制码可以表示为代数多项式g(x) = x^7 + x^5 + x^2 + x +1, 而作为除数的多项式 h(x) 可以自由选择或者按照国际标准选择,一般h(x)的阶数如果是m

boom的博客 1万+

Objective-C中NSDictionary和NSMutableDictionary的基本用法

Objective-C中NSDictionary和NSMutableDictionary的基本用法

Central-Perk的专栏 1万+

【全网最全最详细】Spring与SpringBoot面试题

1.1 什么是Spring?spring的核心实现思想IOC,由spring来负责控制对象的生命周期和对象间的关系。注意以前对于一个类型(类),手动的使用new来实例化这个对象变量,现在不用你new了,交给spring控制。在传统的开发中,在一个类定义另一个类的实例,这样的话,互相依赖,耦合在一起。spring的思想是两个类是独立的,用的时候在往里放,即轻松解耦。1.2 spring优点有哪些?答:可以从四个方面来答,解耦、切面、方便集成各种优秀框架、一站式。

qq_38196449的博客 1049

NSDictionary和NSMutableDictionary的基本用法

一、字典1.NSDictionary: 字典,又叫键值对,字典通过 键(key) 与 值(value) 保存数据, 将键与值绑定在一起,二者必须成对出现2.OC中字典分为:   NSDictionary:不可变字典,一旦初始化, 就不能修改  NSMutableDictionary:可变字典,继承自NSDictionary3.键值对的存储特点    3.1 字典的数据存储, 键值必须一...

qq_36357670的博客 1069

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

Objective-C 字典的基本用法(NSDictionary和NSMutableDictionary)

#import int main(int argc, const char * argv[]) { @autoreleasepool { // insert code here... //创建字典 NSDictionary *dic1 = [NSDictionary dictionaryWithObject:@"value" forKey

asure__cpp的专栏 954

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

NSDictionary和NSMutableDictionary类常用方法的使用

在NSDictionary(不可变字典)中,常使用下面几种方法: 1、先创建一个字典(使用类方法)         NSDictionary* dic1 = [NSDictionary dictionaryWithObjectsAndKeys:@"one",@"ONE",@"two",@"TWO",@'three",@"THREE",@"four",@"FOUR",@'five",@"FIVE

u011874528的专栏 805

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

上一篇: NSArray & NSMutableArray 常用方法
下一篇: 开发Java需要做的准备
喵星人Xcode
博客等级 码龄11年 239粉丝 141原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址