Querying the Database

Retrieve objects from the database by performing fetch requests. A fetch request describes your search criteria for selecting objects. It’s passed through to Core Data and used to initialize a results object that contains an array of fetched objects that meet those criteria. Here is a sample fetch method that saves the resulting fetched results to a local instance variable (_fetchedResultsController) associated with a helper class property:

- (void)fetchItemsMatching:(NSString *)searchString         forAttribute:(NSString *)attribute         sortingBy:(NSString *)sortAttribute {     // Build an entity description     NSEntityDescription *entity = [NSEntityDescription         entityForName:_entityName ...

Get The Core iOS Developer’s Cookbook, Fifth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.