I am building application that has 'checklist' functionality. The checklist item is stored as Core Data entity. There is a 'checked' attribute stored as BOOL
in the Datamodel as well. The view controller handling this checklist functionality is based on UITableViewController
.
Basically, I would like to implement the UIRefreshControl
which allow users to reset the 'checked' status of all checklist entities in Core Data. For example, all the items would be reseted and shown as 'unchecked' once user pulls down the UITableView
.
However, NSFetchedResultsController
only provides access to one entity at a time via [fetchedResultsController objectAtIndexPath:indexPath]
. Would there be a way to get the whole collection of entities from Core Data as NSArray
or NSDictionary
therefore I could enumerate all entities and change their 'checked' attribute?
Agrees with coverback...lets say you want to fetch all the objects from the entity named "Test":
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Test"
inManagedObjectContext:context];
NSError *error;
[fetchRequest setEntity:entity];
NSArray *fetchedObjects = [context executeFetchRequest:fetchRequest error:&error];
fetchObjects array contains all the objects in "Test" entity