我有一個NSFetchedResultsController
正在從NSManagedObjectContext
獲取對象。我正在使用結果填充UITableView。從NSFetchedResultsController設置UITableView標題
我正在過濾這兩個排序描述符。
NSSortDescriptor *lastOpened =
[[NSSortDescriptor alloc] initWithKey:@"lastOpened" ascending:NO];
NSSortDescriptor *titleDescriptor =
[[NSSortDescriptor alloc] initWithKey:@"title" ascending:YES];
當我創建NSFetchedResultsController
,我通過sectionNameKeyPath:@"lastOpened"
切片進行排序。
現在我的部分顯示標準格式,如2009-07-02 20:51:27 -0400由於沒有兩個可以同時打開,它們都是唯一的。我需要它們來涵蓋日期/時間的範圍,例如一整天,並且以人類可讀的形式。類似於7月2日星期四。
謝謝!
編輯:
這畢竟是一個UITableViewController
內。這裏有更多的代碼。
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
// Display the dates as section headings.
return [[[fetchedResultsController sections] objectAtIndex:section] name];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
id <NSFetchedResultsSectionInfo> sectionInfo = [[fetchedResultsController sections] objectAtIndex:section];
return [sectionInfo numberOfObjects];
}
您是否使用綁定來填充表或您是否爲UITableView編寫了數據源? – 2009-07-03 02:13:59