What is ARC?

To understand ARC, you should know a little history. In the old days, Cocoa programmers managed their objects’ reference counts manually by retaining and releasing objects. There were rules, and the rules were fairly simple. This worked well.

Then garbage collection came to Cocoa in 2007. Garbage collection was fine, but it had awkward constraints on the contexts in which it could be used – it was all garbage collection or nothing.

A couple years later, Xcode 3.2 offered an exciting new feature: the Clang Static Analyzer, which knew the retain counting rules and could alert you to memory management errors in your code! Garbage collection never came to iOS. Instead, ARC was announced in 2011, and garbage collection ...

Get Cocoa Programming for OS X: 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.