Objective-C Garbage Collection
Objective-C 2.0 adds garbage collection to the language as a replacement to the traditional retain / release reference counting scheme. Garbage collection is automatic object memory management. The garbage collector figures out what objects are being referred to by other objects, and the collector will destroy the object if nobody has any interest in it. This is familiar behavior to programmers who have used languages like Java or Python, where memory management “just happens.”
Objective-C garbage collection is opt-in. You can choose to use GC or continue to use reference counting. iOS does not currently support GC, so you must use reference counting there. Apple recommends using GC for new apps, but you can retrofit ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access