I was wondering how to combine two array
\'s into one array
.
I want the combined tableView
to show the most recent
I would keep a single property for the table data:
@property (strong, nonatomic) NSMutableArray *tableDataList;
and have a method that is called in each success block:
- (void)addTableData:(NSArray *)items
{
[self.tableDataList addObjectsFromArray:items];
[self.tableDataList sortUsingDescriptors:...];
[self.tableView reloadData];
}
to which you pass mappingResult.array
and you fill in the sort descriptor information to get your timeline ordering.
Then your table view delegate / data source methods are really simple and just refer to self.tableDataList
.
This is relatively similar to the answer from @Larme. From here I would get the item and check the class to decide how to configure the cell:
id item = [self.tableDataList objectAtIndex:indexPath.row];
if ([item isKindOfClass:[Feed class]]) {
Feed *feed = (Feed *)item;
... // configure the feed cell
} else {
Data *data = (Data *)item;
... // configure the data cell
}