Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (NSFetchedResultsController *)fetchedResultsController {
- if (fetchedResultsController != nil) {
- return fetchedResultsController;
- }
- /*
- Set up the fetched results controller.
- */
- // Create the fetch request for the entity.
- NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
- // Edit the entity name as appropriate.
- NSEntityDescription *entity = [NSEntityDescription entityForName:@"Reminder" inManagedObjectContext:managedObjectContext];
- [fetchRequest setEntity:entity];
- // Set the batch size to a suitable number.
- [fetchRequest setFetchBatchSize:20];
- // Edit the sort key as appropriate.
- NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"textContent" ascending:NO];
- NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil];
- [fetchRequest setSortDescriptors:sortDescriptors];
- // Edit the section name key path and cache name if appropriate.
- // nil for section name key path means "no sections".
- NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:managedObjectContext sectionNameKeyPath:nil cacheName:@"Root"];
- aFetchedResultsController.delegate = self;
- self.fetchedResultsController = aFetchedResultsController;
- [aFetchedResultsController release];
- [fetchRequest release];
- [sortDescriptor release];
- [sortDescriptors release];
- return fetchedResultsController;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement