How to change data in NSMutableArray?

Possible duplicate:
How to display an array in reverse order in a C object

I have NSMutableArray, and this array contains information in UITableView. but I want to first display the latest information in UITableView. Right now the earliest information comes first at UITableView. My code is as follows:

NSMutableArray *entries = [NSMutableArray array];
[self parseFeed:doc.rootElement entries:entries];
for (RSSEntry *entry in entries) {
    [allEntries insertObject:entry atIndex:0];   //insertIdx];
    [self.tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:0 inSection:0]] withRowAnimation:UITableViewRowAnimationRight];
}

then How to change the information in NSMutableArray?

+5
source share
2 answers

How to simply list contents entriesin reverse order?

for (RSSEntry *entry in [entries reverseObjectEnumerator]) {
    ...
}

If you just want to take an array and create a return array, you can do this:

NSArray *reversedEntries = [[entries reverseObjectEnumerator] allObjects];
+13

:

for (int k = [originalArray count] - 1; k >= 0; k--) {
    [reverseArray addObject:[originalArray objectAtIndex:k]];
}
+7

All Articles