NSFetchedResultsController を使用するテーブルがあります。これにより、存在するヘッダーのインデックスが取得されます
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return [[_fetchedResultsController sections] count];
}
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
return [[[_fetchedResultsController sections] objectAtIndex:section] name];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
NSInteger numberOfRows = 0;
NSArray *sections = _fetchedResultsController.sections;
if(sections.count > 0)
{
id <NSFetchedResultsSectionInfo> sectionInfo = [sections objectAtIndex:section];
numberOfRows = [sectionInfo numberOfObjects];
}
return numberOfRows;
}
- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView
{
return [_fetchedResultsController sectionIndexTitles];
}
- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index
{
return [_fetchedResultsController sectionForSectionIndexTitle:title atIndex:index];
}
しかし、UILocalizedIndexCollation を使用して完全なアルファベットを取得したいと考えています。
これらのメソッドを NSFetchedResultsController に接続するにはどうすればよいですか?
現在の照合順序からインデックス タイトルを取得する必要があると思います
- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView
{
return [[UILocalizedIndexedCollation currentCollation] sectionIndexTitles];
}
しかし、私はこのメソッドの書き方に迷っています
- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index
{
//How do I translate index here to be the index of the _fetchedResultsController?
return [_fetchedResultsController sectionForSectionIndexTitle:title atIndex:index];
}