AppDelegate’s CoreDataHelper Instance

Frequently throughout the application, access will be required to the shared instance of CoreDataHelper. This means that the existing cdh code found in AppDelegate.m needs to be exposed through AppDelegate.h. Listing 5.6 shows the code required to expose cdh.

Listing 5.6 AppDelegate.h: cdh

- (CoreDataHelper*)cdh;

Update Grocery Dude as follows to expose the cdh method:

1. Add the code from Listing 5.6 to the bottom of AppDelegate.h before @end.

The existing implementation of cdh is intended to return the shared instance of CoreDataHelper. At present, this method isn’t thread-safe because there’s no guarantee that CoreDataHelper won’t be instantiated more than once from separate threads. An updated version ...

Get Learning Core Data for iOS: A Hands-On Guide to Building Core Data Applications 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.