ミュージシャンのアルバムを表示するテーブル ビューがあります。各セクションはアルバム、各行はトラックです。アルバム/セクションをリリース日順、次にタイトル順で並べ替える必要があります。次のように Core Data からトラックを取得しています。
fetchRequest = [[NSFetchRequest alloc] init];
...
fetchRequest.sortDescriptors = [NSArray arrayWithObjects:
[NSSortDescriptor sortDescriptorWithKey:@"album.releaseDate" ascending:YES],
[NSSortDescriptor sortDescriptorWithKey:@"album.title" ascending:YES],
[NSSortDescriptor sortDescriptorWithKey:@"trackNumber" ascending:YES],
nil];
frc = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest
managedObjectContext:context
sectionNameKeyPath:@"album.releaseDate" // <-- PROBLEM HERE
cacheName:nil];
リリース日が同じ 2 つのアルバムが同じセクションに表示されるため、これは機能しません。
セクション名キーパスとして album.title を使用すると、セクションがアルファベット順に並べ替えられ、トラック (日付、タイトル、トラック番号で並べ替えられます) に適用されるため、地獄が解き放たれます。
セクションを日付順、次にタイトル順で並べ替えるにはどうすればよいですか?