A simple UIViewController subclass that implements NSFetchedResultsControllerDelegate and manages a table view binded to a custom fetch request.
- Simple fetch requests
- Support of sections
- Simple customization via overriding
- Use Offset to manage custom sections or rows (at the top)
- Addional Filter Controller (inspired by: lukagabric/LargeDatasetSample)
Not yet contributed but you can include it via:
pod 'QMBFetchedResultsViewController', :git => 'https://github.com/quemb/QMBFetchedResultsViewController.git'
Set your managed object context via override:
- (NSManagedObjectContext *)managedObjectContext { return [((QMBAppDelegate *)[[UIApplication sharedApplication] delegate]) managedObjectContext]; }
Set your fetch Request (section is optional):
- (NSFetchRequest *)getFetchRequest { NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"Sample" inManagedObjectContext:[self managedObjectContext]]; [fetchRequest setEntity:entity]; [fetchRequest setSortDescriptors:[NSArray arrayWithObjects: [[NSSortDescriptor alloc] initWithKey:@"title" ascending:YES], nil]]; return fetchRequest; }
Set your UITableViewCell - styles
- (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath { Sample *sample = (Sample *)[self.fetchedResultsController objectAtIndexPath:indexPath]; cell.textLabel.text = sample.title; cell.detailTextLabel.text = sample.subtitle; }