For the More Curious: Autorelease Pool and ARC History

Before automatic reference counting (ARC) was added to Objective-C, we had manual reference counting. With manual reference counting, ownership changes only happened when you sent an explicit message to an object.

[​a​n​O​b​j​e​c​t​ ​r​e​l​e​a​s​e​]​;​ ​/​/​ ​a​n​O​b​j​e​c​t​ ​l​o​s​e​s​ ​a​n​ ​o​w​n​e​r​

[​a​n​O​b​j​e​c​t​ ​r​e​t​a​i​n​]​;​ ​/​/​ ​a​n​O​b​j​e​c​t​ ​g​a​i​n​s​ ​a​n​ ​o​w​n​e​r​

This was a bummer: Forgetting to send release to an object before setting a pointer to point at something else would create a memory leak. Sending release to an object if you had not previously sent retain to the object was a premature deallocation. A lot of time was spent debugging ...

Get iOS 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.