Automatic Reference Counting (ARC)

Automatic Reference Counting (ARC) is a compiler-level feature that simplifies the process of managing the lifetimes of Objective-C objects. Instead of you having to remember when to retain or release an object, ARC evaluates the lifetime requirements of your objects and automatically synthesizes the appropriate method calls at compile time. It isn’t a new runtime memory model — and it isn’t a garbage collector. All the action takes place in the compiler.

ARC takes care of the process of retaining and releasing objects by taking advantage of (and having the compiler enforce) naming conventions. It also relies on new object pointer ownership qualifiers (more on that later.)

Lest you worry, ARC is actually much faster (has better performance) than doing memory management on your own.

warning_bomb.eps ARC doesn’t automate malloc() and free() ( C functions I won’t get into here) and doesn’t automate CoreFoundation (CF) or CoreGraphics (CG). You’ll be using some of those kinds of functions, and I talk about them in Chapter 10.

To be able to manage memory for you, ARC imposes some restrictions — primarily enforcing some best practices and disallowing some other practices. You won’t have to worry about most of this in an application that was created to use ARC. You may see some things in non-ARC samples, but hopefully my discussion here will help you figure out how to ...

Get iPad Application Development For Dummies, 3rd 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.