NSFetchedResultsControllerとNSSortDescriptorを使用して、各日付のセクションを持つテーブルに正常に並べ替えているので、今日の日付が最初に表示されます(日付の降順)。
ただし、そのセクションでは、時間を昇順で並べ替えてほしいと思います。
これは、時間でソートしない現在のコードです。
//Set up the fetched results controller.
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:kEntityHistory inManagedObjectContext:global.managedObjectContext];
fetchRequest.entity = entity;
// Sort using the timeStamp property..
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"date" ascending:NO];
NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil];
fetchRequest.sortDescriptors = sortDescriptors;
//The following is from:
//http://stackoverflow.com/questions/7047943/efficient-way-to-update-table-section-headers-using-core-data-entities
NSString *sortPath = @"date.dayDate";
self.fetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:global.managedObjectContext sectionNameKeyPath:sortPath cacheName:nil];
fetchedResultsController.delegate = self;
この日付セクション内で時間の昇順で並べ替えを追加するようにコードを変更するにはどうすればよいですか?