2012-09-20 3 views
0

pubcast에서 알파벳순으로 정렬하는 중 내 podcast보기를 변경하려고합니다. 날짜를 현재 RSS를 구문 분석에 사용 된 코드는 다음과 같습니다iPhone에서 TableView보기 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]; 

      } 

     }]; 

이 어떻게 다른 항목의 호텔 중 한 알파벳 순으로 바로 이럴 변경할 수 있습니까?

+1

방금 ​​라인'[ENTRY1을 수정할 수 없습니다. articleDate compare : entry2.articleDate];'다른 속성을 비교 하시겠습니까? –

+0

또는'sort' 스크립트를 사용하여'tableView'에 표시하면서 정렬 할 수도 있습니다. – vishy

답변

0

나는 당신이 비교 라인을 대체 할 수 있다고 생각 :

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

그런 식으로 (가정이있는 NSString되는 객체) :

return [entry1.articleTitle localizedCaseInsensitiveCompare:entry2.articleTitle];