Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 9. Memory management > Reference counting

9.2. Reference counting

Objective-C uses reference counting to implement the concept of object ownership. Every object keeps an internal count of how many times it has been owned (commonly called the object’s retain count). Each time something puts its hand up and says, “I need this object,” the retain count is incremented, and each time something says it no longer needs an object, the count is decremented.

If the counter is decremented back to zero, the object has no current owner and hence can be deallocated by the runtime.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial