强制特定的NSFetchedResultsController部分到底部

时间:2015-03-12 14:41:02

标签: ios uitableview core-data nsfetchedresultscontroller

我想移动我的NSFetchedResultsController返回的一个特定部分放在底部。我想保持其他部分的排序顺序。有没有办法覆盖特定的顺序?

这是我的NSFetchedResultsController创建:

- (NSFetchedResultsController *)fetchedResultsController
{
    if (_fetchedResultsController != nil) {
        return _fetchedResultsController;
    }
    NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
    NSEntityDescription *entity = [NSEntityDescription entityForName:@"Object" inManagedObjectContext:self.managedObjectContext];
    [fetchRequest setEntity:entity];
    NSSortDescriptor *descriptor = [[NSSortDescriptor alloc] initWithKey:@"type" ascending:YES];
    [fetchRequest setSortDescriptors:[NSArray arrayWithObjects:teacherString, descriptor, nil]];
    NSString *downloadedString = @"Downloaded";
    fetchRequest.predicate = [NSPredicate predicateWithFormat:@"
status like[cd] %@",downloadedString];
    [fetchRequest setFetchBatchSize:20];
    _fetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest
                                                                    managedObjectContext:self.managedObjectContext
                                                                      sectionNameKeyPath:@"title"
                                                                               cacheName:nil];
    _fetchedResultsController.delegate = self;
    self.fetchedResultsController = _fetchedResultsController;
    return _fetchedResultsController;
}

例如,我希望获得以U开头的标题始终显示在UITableView的底部,但仍然可以适当地响应新对象插入。

当我使用排序描述符时,它会对部分进行排序,然后对部分中的行进行排序。

0 个答案:

没有答案