Automatic Reference Counting
Now is a good time to talk about Automatic Reference Counting, otherwise known as ARC. If you are an Objective-C programmer, then you know all about ARC. If you were one of the first iPhone programmers, you know that you used to have to do your own reference counting. You will be happy to know that for the most part, you can let Swift worry about the management of memory.
When you create instances of classes, those classes exist by reference. When those instances are no longer needed, Swift cleans them up for you.
ARC works by keeping track of the instances of classes that you create and where those instances are referenced. Every time you create a new instance of a class, ARC finds some free memory available where ...
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