Skip to content
Snippets Groups Projects
Commit 8e48d27d authored by cramakri's avatar cramakri
Browse files

Fixed sorting of entities -- it matches natural (Finder) sorting

SVN: 27620
parent 67c8e627
No related branches found
No related tags found
No related merge requests found
...@@ -176,6 +176,13 @@ ...@@ -176,6 +176,13 @@
} }
#pragma mark - Fetched results controller #pragma mark - Fetched results controller
- (void)applyStandardSortDescriptorsToFetchRequest:(NSFetchRequest *)fetchReqeust
{
NSSortDescriptor *categorySortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"category" ascending: NO];
NSSortDescriptor *summaryHeaderSortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"summaryHeader" ascending: YES selector: @selector(localizedStandardCompare:)];
NSArray *sortDescriptors = @[categorySortDescriptor, summaryHeaderSortDescriptor];
[fetchReqeust setSortDescriptors: sortDescriptors];
}
- (void)initializeRootFetchedResultsController - (void)initializeRootFetchedResultsController
{ {
...@@ -187,11 +194,7 @@ ...@@ -187,11 +194,7 @@
NSPredicate *predicate = [NSPredicate predicateWithFormat: @"rootLevel == YES"]; NSPredicate *predicate = [NSPredicate predicateWithFormat: @"rootLevel == YES"];
[fetchRequest setPredicate: predicate]; [fetchRequest setPredicate: predicate];
NSSortDescriptor *categorySortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"category" ascending: NO]; [self applyStandardSortDescriptorsToFetchRequest: fetchRequest];
NSSortDescriptor *summaryHeaderSortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"summaryHeader" ascending: YES];
NSArray *sortDescriptors = @[categorySortDescriptor, summaryHeaderSortDescriptor];
[fetchRequest setSortDescriptors:sortDescriptors];
NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest: fetchRequest managedObjectContext: self.managedObjectContext sectionNameKeyPath: @"category" cacheName: @"Root"]; NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest: fetchRequest managedObjectContext: self.managedObjectContext sectionNameKeyPath: @"category" cacheName: @"Root"];
aFetchedResultsController.delegate = self; aFetchedResultsController.delegate = self;
...@@ -217,10 +220,7 @@ ...@@ -217,10 +220,7 @@
nil]; nil];
NSFetchRequest *fetchRequest = [model fetchRequestFromTemplateWithName: @"EntityAndChildren" substitutionVariables: fetchVariables]; NSFetchRequest *fetchRequest = [model fetchRequestFromTemplateWithName: @"EntityAndChildren" substitutionVariables: fetchVariables];
NSSortDescriptor *categorySortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"category" ascending: NO]; [self applyStandardSortDescriptorsToFetchRequest: fetchRequest];
NSSortDescriptor *summaryHeaderSortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"summaryHeader" ascending: YES];
NSArray *sortDescriptors = @[categorySortDescriptor, summaryHeaderSortDescriptor];
[fetchRequest setSortDescriptors:sortDescriptors];
NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest: fetchRequest managedObjectContext: self.managedObjectContext sectionNameKeyPath: @"category" cacheName: _parentModel.selectedObject.permId]; NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest: fetchRequest managedObjectContext: self.managedObjectContext sectionNameKeyPath: @"category" cacheName: _parentModel.selectedObject.permId];
aFetchedResultsController.delegate = self; aFetchedResultsController.delegate = self;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment