16. ARC

Memory management is the bane of programming in Objective-C. Beginners find it confusing and difficult to learn. Even experienced Objective-C programmers seem to have trouble following the rules from time to time. The result is often memory leaks, crashes, and hours spent chasing memory bugs. Over the past years Apple has made several attempts to make the task of memory management less onerous.

The first attempt was garbage collection (GC). In a program that uses garbage collection a separate thread wakes up periodically, examines the program’s memory, and returns objects that are not being used to the heap. Unfortunately, GC impacts performance and has other issues. GC was never available on iOS, and it is deprecated in OS X beginning ...

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.