Previously, we used NSArray
to store the response data and to show it in UITableView
. With Core Data entities, the best approach is to use NSFetchedRequestController
. The benefit of using it is its ability of lazy loading objects, as well as responding to Core Data changes on fetched objects.
Let's modify our GenericTableViewController
to support Core Data in addition to in-memory objects. We will start by defining a few additional properties:
@property (nonatomic, assign) BOOL useCoreData; @property (nonatomic, assign) Class objectClass; @property (nonatomic, strong) NSString *sortBy; @property (nonatomic, strong) NSString *groupBy; @property (nonatomic, strong) NSPredicate *fetchPredicate; @property (nonatomic, strong) NSFetchedResultsController *fetchedResultsController;
A brief description of the properties we are using:
Property name |
Type |
Description |
---|---|---|
|
|
Assign |
|
|
Class of objects that are... |