数组与字典的应用
来源:互联网 发布:在线打电话软件 编辑:程序博客网 时间:2024/06/08 03:32
一组数据有图片及文字描述
// 设置数组属性
@interface
@property (nonatomic, strong) NSArray *imageData;
@property (nonatomic, assign) int index;
@end
@implementation // 创建包含 图片名称及描述 的字典 NSMutableDictionary *imageWithDesc1 = [NSMutableDictionary dictionary];
imageWithDesc1[@"icon"] = @"图片名称1"; imageWithDesc1[@"desc"] = @"图片描述1"; NSMutableDictionary *imageWithDesc2 = [NSMutableDictionary dictionary]; imageWithDesc2[@"icon"] = @"图片名称2"; imageWithDesc2[@"desc"] = @"图片描述2"; NSMutableDictionary *imageWithDesc3 = [NSMutableDictionary dictionary]; imageWithDesc3[@"icon"] = @"图片名称3"; imageWithDesc3[@"desc"] = @"图片描述3";
<pre name="code" class="objc"><span style="white-space:pre"></span>
// 创建数组
self.imageData = @[imageWithDesc1, imageWithDesc2, imageWithDesc3];
<pre name="code" class="objc"> // 提出数组里index对应的字典数据
NSArray *imageDict = imageData[self.index];
<pre name="code" class="objc"> // 设置图片名称
NSString *iconName = imageDict[@"icon"];
// 设置图片描述
NSString *iconDesc = imageDict[@"desc"];
</pre><pre name="code" class="objc"><span style="font-family: Arial, Helvetica, sans-serif;">@end</span>
0 0
- 数组与字典的应用
- 数组和字典的组合应用
- 数组和字典的应用数据
- 字典+数组的应用——省市区
- 字典与数组的相互包含
- oc中数组与字典的总结
- python中字典的操作与应用
- Javascript 数组与字典
- swift数组与字典
- 指针数组与二维数组的应用
- 写文件数组与字典
- swift -入门与 数组 字典
- OC数组与字典详解
- 字典树的指针模板与数组模板
- 字典与数组嵌套使用时遇到的一些问题
- objective-c 省市区练习(数组与字典的嵌套)
- 字典或者数组与JSON串之间的转换
- Python字典的应用
- 小小君的C语言第四课
- ios面试题
- 微软官方网站提供 MASM 8.0软件包(x86)下载,有简体中文版
- Codevs1161 抢掠计划
- iOS单例设计模式
- 数组与字典的应用
- C++/Java__中类模板中的静态成员变量和静态成员函数
- python学习-数据分析2(分类型数据处理+SVM建模)
- CABasicAnimation的基本使用方法(移动·旋转·放大·缩小)
- 创建带Apache服务的Centos Docker镜像
- Windows命令启动MySQL“ 发生系统错误 5 ”
- 面向对象四大特征
- object-c中NSString与int和float的相互转换
- java设计模式之抽象工厂模式