Tsallaka zuwa abun ciki
Justice Tech School

Memory and ARC

Swift counts references to class instances. Use weak or unowned to avoid retain cycles.

Example
class Node {
    weak var next: Node?
    deinit { print("freed") }
}
var a: Node? = Node()
a = nil

Exercise

Avoid cycles.

 var next: Node?

Quiz Test

What does ARC do?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.