How can I append one NSMutableArray to another, from what I’ve seen, it sound be fairly straight forward. But I’m getting some weird results, I think the amount of items in my temp array are being added but the dictionary values are being lost.
This is my current code, where I just overwrite my self.transactionArray
h - file
NSMutableArray *transactionArray;
@property (nonatomic, retain) NSMutableArray *transactionArray;
m - file
NSMutableArray *arrayTmp= [[NSMutableArray alloc] init];
//start loop
[arrayTmp addObject:[NSDictionary dictionaryWithObjectsAndKeys:desc,@"desc",
due,@"due",nil]];
//release nsstring desc etc
//end loop
self.transactionArray = arrayTmp;
[arrayTmp release];
My second attempt…
NSMutableArray *array1 = [arrayTmp mutableCopy];
[self.transactionArray addObjectFromArray:array1];
This was my first attempt…
[self.transactionArray addObjectFromArray:arrayTmp];
What am I doing wrong ?
You can do that like this:
And on a side note, please always read the documentation before posting a question. This method is easily found in the
NSMutableArraydocumentation.