我已經看過以下資源: NSDictionary to NSArray? https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSMutableArray_Class/Reference/Reference.html https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSDictionary_Class/Reference/Reference.html如何將NSDictionary對象添加到NSMutableArray?
什麼,我試圖做的是插入一個NSDictionary到一個NSMutableArray。
相關的代碼似乎是這樣對我說:
NSDictionary *aDic= [NSDictionary dictionaryWithObjectsAndKeys:
@"Carlos", @"name",
@"Jimenez", @"lastName", nil];
//On initialization
NSMutableArray *aArr = [NSMutableArray arrayWithObjects:aDic,nil];
//After initialization
NSMutableArray *aArr2 = [NSMutableArray array]; [aArr2 addObject:aDic];
:
@property (strong,nonatomic) NSMutableArray * curveList;
@property (strong,nonatomic) UIBezierPath * curPath;
@property (strong, nonatomic) UIColor * curColor;
// some code to set curPath and curColor
@{@"path":_curPath, @"color":_curColor}
//how to insert this into self.curveList???
看看'NSMutableArray'的文檔。有一個非常明顯的添加對象的方法。 – rmaddy 2014-10-08 16:05:21
您可以像添加任何其他對象一樣添加NSDictionary。 – Jsdodgers 2014-10-08 16:07:15
與setObject:forKey:方法? – 2014-10-08 16:11:10