NLFetchedResultsTable is a project mainly written in OBJECTIVE-C and C, it's free.
A small open-source library that lets you quickly create a UITableViewController that is backed by an NSFetchedResultsController.
NLFetchedResultsTable
is a small open-source class that helps you
quickly create and configure a UITableViewController
that is backed
by an NSFetchedResultsController
. This is code I use in a lot of my
projects, and have extracted into its own class. The primary benefit
of using an NLFetchedResultsTable
is that it handles a lot of the
NSFetchedResultsControllerDelegate
and UITableViewDataSource
methods
for you.
You can create and instantiate an NLFetchedResultsTable
on its own,
or you can subclass it to customize to your liking. In the sample
code, the app delegate creates an instance of RootViewController with
the following:
RootViewController *rootViewController = (RootViewController *)[navigationController topViewController];
rootViewController.managedObjectContext = self.managedObjectContext;
rootViewController.entityName = @"Event";
rootViewController.cellTextLabelKey = @"name";
rootViewController.cellDetailTextLabelKey = @"timeStamp";
The RootViewController class subclasses NLFetchedResultsTable
to
provide its own add and edit records functionality.
After creating an NLFetchedResultsTable
or a subclass of NLFetchedResultsTable
,
the following properties are required to be set prior to displaying:
NSManagedObjectContext
from which to fetch objectsUITableViewCell
sThe following properties can optionally be set to add functionality to
the NLFetchedResultsController
:
UITableViewCell
s that are createdNSArray
of sortDescriptors to use. By default an NLFetchedResultsTable
will sort by the cellTextLabelKey.This code is free for anyone to use in personal or commercial projects under the Creative Commons Attribution 3.0 license (http://creativecommons.org/licenses/by/3.0/).
Any comments or suggestions that would help improve this code are always welcome! Enjoy!