Recall & Review
beginner
What does ARC stand for in Swift?
ARC stands for Automatic Reference Counting. It helps manage memory by keeping track of how many references point to an object.
Click to reveal answer
beginner
How does ARC decide when to free an object?
ARC frees an object when its reference count drops to zero, meaning no part of the code is using it anymore.
Click to reveal answer
beginner
What is a strong reference in ARC?
A strong reference is the default way Swift keeps an object alive by increasing its reference count when assigned.
Click to reveal answer
intermediate
What problem can strong reference cycles cause?
Strong reference cycles happen when two objects hold strong references to each other, preventing ARC from freeing them and causing memory leaks.
Click to reveal answer
intermediate
How can you break a strong reference cycle in Swift?
You can use weak or unowned references to break strong reference cycles. These references do not increase the reference count.
Click to reveal answer
What happens when an object's reference count reaches zero in ARC?
✗ Incorrect
When the reference count is zero, ARC automatically frees the object's memory.
Which type of reference increases an object's reference count in Swift ARC?
✗ Incorrect
Strong references increase the reference count, keeping the object alive.
What keyword is used in Swift to declare a weak reference?
✗ Incorrect
The 'weak' keyword declares a weak reference that does not increase the reference count.
Why are strong reference cycles problematic?
✗ Incorrect
Strong reference cycles keep objects alive forever, causing memory leaks.
Which reference type should you use when you know the referenced object will always exist during the reference's lifetime?
✗ Incorrect
Unowned references are used when the referenced object is expected to always exist while the reference exists.
Explain how ARC manages memory in Swift and what happens when an object's reference count changes.
Think about how Swift keeps track of who is using an object.
You got /3 concepts.
Describe what a strong reference cycle is and how to prevent it in Swift.
Consider how two friends holding hands tightly might never let go.
You got /3 concepts.