FetchedResultsController 2.0.7

FetchedResultsController 2.0.7

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Apr 2016
SPMSupports SPM

Maintained by William Boles.



  • By
  • William Boles

A FetchedResultsController implementation that abstracts out the boilerplate for UITableView

Usage

FetchedResultsController is a collection of subclasses of NSFetchedResultsController that conform to their own NSFetchedResultsControllerDelegate delegate and implement these methods to handle the most common use case. As this implementation uses it’s own delegate we have had to introduce a different suite of delegate callbacks: FRCTableViewFetchedResultsControllerDataDelegate.

Configuring

Tableview
- (FRCTableViewFetchedResultsController *)fetchedResultsController
{
    if (!_fetchedResultsController)
    {
        _fetchedResultsController = [[FRCTableViewFetchedResultsController alloc] initWithFetchRequest:self.fetchRequest
                                                                                  managedObjectContext:[CDSServiceManager sharedInstance].managedObjectContext
                                                                                    sectionNameKeyPath:nil
                                                                                             cacheName:nil];

        _fetchedResultsController.tableView = self.tableView;

        [_fetchedResultsController performFetch:nil];
    }

    return _fetchedResultsController;
}
Mixing different datasources

At times you want to mix data from your FRC with data from another source inside the same UITableView to support this FetchedResultsController has a sectionOffset property that will allow you to insert multiple non-FRC’d sections into your view. It’s important to note that this only works for sections that come before (lower index) the FRC section.

_fetchedResultsController.sectionOffset = 2;

In the above example we add two sections before the FRC section.

FetchedResultsController comes with an example project to provide more details than listed above.

FetchedResultsController uses modules for importing/using frameworks - you will need to enable this in your project.

Found an issue?

Please open a new Issue here if you run into a problem specific to FetchedResultsController, have a feature request, or want to share a comment. Note that general FetchedResultsController/Core Data questions should be asked on Stack Overflow.

Pull requests are encouraged and greatly appreciated! Please try to maintain consistency with the existing code style. If you’re considering taking on significant changes or additions to the project, please communicate in advance by opening a new Issue. This allows everyone to get onboard with upcoming changes, ensures that changes align with the project’s design philosophy, and avoids duplicated work.