Chapter    49

Automatic Reference Counting

As your Swift program creates new instances, memory resources are used to store the information associated with each instance. When an instance is no longer needed, Swift will reclaim the resources associated with the instance so that these resources can be used with other instances.

The system that Swift uses to keep track of all your instances is called automatic reference counting (ARC). ARC works because Swift can keep a count of how many times an instance is referenced in a program. This is called the reference count. For the most part, you don’t need to manage this yourself since Swift takes care of reference counting automatically.

Note  In Chapter 42, you coded a deinit, which is a special ...

Get Swift Quick Syntax Reference 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.