I have an iPhone application in which i am trying to add two mutable arrays.
NSMutableArray *dataArray = [[NSMutableArray alloc] init];
NSMutableArray *dataArray1 = [[NSMutableArray alloc] init];
NSDictionary *news = [dict objectForKey:@"news"];
NSDictionary *deals = [dict objectForKey:@"deals"];
NSLog(@"%@", [news classForCoder]);
NSLog(@"%@", news);
for (NSDictionary *key in news)
{
if ([key isKindOfClass:[NSDictionary class]])
{
[dataArray addObject:key];
}
}
for (NSDictionary *key in deals)
{
if ([key isKindOfClass:[NSDictionary class]])
{
[dataArray1 addObject:key];
}
}
self.newssarray = dataArray;
[self.mTableView reloadData];
Here I want to add the two arrays 'dataArray' and 'dataArray2' to be combined into one array (self.newsarray
). Can anybody help me in achieving this?
NSMutable array has all of NSArray's methods, including one for creating a new array by adding another array to itself:
self.newsarray = [[dataArray arrayByAddingObjectsFromArray:dataArray1] mutableCopy];