O'Reilly logo

Objective-C Memory Management Essentials by Gibson Tang, Maxim Vasilkov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Getting into the code

Let's get started with our code examples:

  1. For our code, we will first declare some Core Data objects in our AppDelegate class inside our AppDelegate.h file such as:
    @property (readonly, strong, nonatomic) NSManagedObjectContext
    *managedObjectContext;
    @property (readonly, strong, nonatomic) NSManagedObjectModel
    *managedObjectModel;
    @property (readonly, strong, nonatomic) NSPersistentStoreCoordinator
    *persistentStoreCoordinator;

    These are declared here so that we can access them easily from any screen.

  2. Next, we will declare the code for each of the objects in AppDelegate.m such as the following lines of code that will create an instance of NSManagedObjectContext and return an existing instance if the instance already exists. This ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required