0

我正在尝试将我的播客视图从通过 pubDate 排序更改为按字母顺序排序。当前用于解析日期的 RSS 的代码是:

 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 = (RSSEntry *) a;
                    RSSEntryDirectory *entry2 = (RSSEntry *) b;
                    return [entry1.articleDate compare:entry2.articleDate];
                }];

                [_allEntries insertObject:entry atIndex:insertIdx];
                [self.tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:insertIdx inSection:0]]
                                      withRowAnimation:UITableViewRowAnimationRight];

            }

        }];

如何将其更改为仅按其他条目属性之一按字母顺序执行?

4

1 回答 1

0

我认为您可以替换比较行:

return [entry1.articleDate compare:entry2.articleDate];

通过类似的方式(假设它是 NSString 对象):

return [entry1.articleTitle localizedCaseInsensitiveCompare:entry2.articleTitle];
于 2012-09-20T19:48:59.400 回答