0
我通常通過解析XML解析博客應用程序,然後排序以獲取pubDate並首先顯示最新的應用程序。要做到這一點,我解析結束時使用此:將項目添加到NSMutableArray並按字母順序排序
NSMutableArray *entries = [NSMutableArray array];
[self parseFeed:doc.rootElement entries:entries];
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
for (RSSEntryDirectory *entry in entries) {
int insertIdx = [_allEntries indexForInsertingObject:entry sortedUsingBlock:^(id a, id b) {
RSSEntryDirectory *entry1 = (RSSEntryDirectory *) a;
RSSEntryDirectory *entry2 = (RSSEntryDirectory *) b;
return [entry1.articleDate compare:entry2.articleDate];
}];
[_allEntries insertObject:entry atIndex:insertIdx];
[self.tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:insertIdx inSection:0]]
withRowAnimation:UITableViewRowAnimationRight];
}
}];
我想需要做的就是簡單地採取從標題標籤的文本,並把它添加到NSMutableArray中按字母順序。