1. 程式人生 > >ios手動添加數組字典(NSMutableDictionary)

ios手動添加數組字典(NSMutableDictionary)

code tom 添加 取數 array color text class 數組

@property (nonatomic,strong) NSArray *imageData;//定義一個數組

-(NSArray *)imageDate
{
if(_imageDate==nil)
{
NSMutableDictionary *image1=[NSMutableDictionary dictionary];
image1["icon"]=@"a";
image1["title"]=@"測試一";

NSMutableDictionary *image2=[NSMutableDictionary dictionary];
image2["icon"]=@"a";
image2[
"title"]=@"測試二"; NSMutableDictionary *image3=[NSMutableDictionary dictionary]; image3["icon"]=@"a"; image3["title"]=@"測試三"; _imageData=@[image1,image2,image3]; } return _imageData; }
//讀取數據
NSDictionary *imageDict=self.imageData[0];
self.icon.text=imageDict[@"icon"];
self.title.text=imageDict[@"title
"];

 

ios手動添加數組字典(NSMutableDictionary)