15 Objects and Memory

In this chapter, you will learn about the life of objects on the heap and how heap memory is managed.

On pointers and their values

Objects can only be accessed via a pointer, and it is practical, if inaccurate, to refer to an object by its pointer, as in now is an NSDate. However, is important to remember that the pointer and the object that it points at are not the same thing. Here is a more accurate statement: now is a pointer that can hold an address of a location in memory where an instance of NSDate lives.

Create a new Command-line Tool named TimesTwo. Make its type Foundation. In main.m, declare a variable that points to an instance of NSDate.

#import <Foundation/Foundation.h> int main ...

Get Objective-C Programming: The Big Nerd Ranch Guide 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.