标签:
一、字典的使用
NSMutableDictionary *image1 = [NSMutableDictionary dictionary]; //新建一个字典 image1[@"icon"] = @"chiniupa"; //存储一张名叫chiniupa的照片,索引为icon image1[@"discr"]= @"吃牛扒吧"; //存储一段”吃牛扒吧“这段文字,索引为discr 如果要提前里面的内容,用image1[@"icon"]即可提取该照片
二、数组的使用
首先要先在interface理声明
@property (nonatomic, strong) NSArray * storeData;
然后进行存储数据
- (NSArray *) storeData{ if (_storeData == nil) { //延时加载 NSMutableDictionary *image1 = [NSMutableDictionary dictionary];
image1[MJIconKey] = @"chiniupa"; image1[MJDescKey]= @"吃牛扒"; NSMutableDictionary *image2 = [NSMutableDictionary dictionary]; image2[MJIconKey] = @"bingli"; image2[MJDescKey]= @"兵力"; NSMutableDictionary *image3 = [NSMutableDictionary dictionary]; image3[MJIconKey] = @"wangba"; image3[MJDescKey]= @"王八"; _storeData = @[image1, image2, image3];} return _storeData; }
调用数组时
self.storeData[0]; //调用了0号位的数据
三、添加图片
self.imageView.image = [UIImage imageNamed:image[DITI]];
标签:
原文地址:http://www.cnblogs.com/xcodeios/p/4278911.html