Retrieve Data from Core Data

In the previous chapter, you saw how to save data to Core Data by inserting a Contact object into the managed object context. Retrieving data is similar, but instead of inserting objects, you will fetch them, and then specify some action to take on the retrieved objects. Listing 12.2 shows the changes you need to make in LMAContactsTableController.m to have the data show up from the database.

Listing 12.2 Retrieving Data from Core Data in LMAContactsTableController.m

#import "LMAContactsTableController.h"#import "LMAAppDelegate.h"                                                       //1#import "Contact.h"@interface LMAContactsTableController ()@endNSArray *contacts;LMAAppDelegate *appDelegate;                                                     //2 ...

Get Learning Mobile App Development: A Hands-on Guide to Building Apps with iOS and Android 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.