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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.