15. Reference Counting

With the introduction of Automatic Reference Counting in the spring of 2011, Apple has begun referring to the traditional Objective-C reference counting system as manual reference counting. For the sake of brevity I will use the term reference counting to refer to the manual system and the term ARC to refer to Automatic Reference Counting. This chapter covers manual reference counting.

Reference Counting Basics

Reference counting is very simple in principle. Each object stores a count, called the reference count or retain count, of the other objects that are using it. When you first create an object using alloc, its retain count is one. You own the object. When you no longer need the object, you indicate that you are finished ...

Get Learning Objective-C 2.0: A Hands-on Guide to Objective-C for Mac and iOS Developers, Second 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.