Recall & Review
beginner
What does ARC stand for in Swift?
ARC stands for Automatic Reference Counting. It is a memory management feature in Swift that automatically tracks and manages the app's memory usage.
Click to reveal answer
beginner
Why is ARC important for Swift developers?
ARC helps Swift developers by automatically freeing up memory when objects are no longer needed, preventing memory leaks and crashes without manual intervention.
Click to reveal answer
intermediate
How does ARC know when to free an object’s memory?
ARC keeps track of how many strong references point to an object. When the count drops to zero, meaning no one is using the object, ARC frees its memory.
Click to reveal answer
intermediate
What is a strong reference cycle and why is it a problem in ARC?
A strong reference cycle happens when two objects hold strong references to each other, so their reference counts never reach zero. This causes memory leaks because ARC can’t free them.
Click to reveal answer
intermediate
Name two ways Swift developers can avoid strong reference cycles.
Developers can use weak or unowned references to break strong reference cycles. Weak references don’t increase the reference count and can become nil, while unowned references assume the object always exists during their lifetime.
Click to reveal answer
What triggers ARC to free an object’s memory?
✗ Incorrect
ARC frees an object’s memory when no strong references point to it, meaning its reference count is zero.
Which of the following can cause a memory leak in Swift?
✗ Incorrect
Strong reference cycles keep objects alive forever because their reference counts never reach zero, causing memory leaks.
What type of reference does NOT increase an object's reference count?
✗ Incorrect
Weak references do not increase the reference count and can become nil when the object is deallocated.
Which keyword in Swift is used to declare a weak reference?
✗ Incorrect
The 'weak' keyword declares a weak reference that does not increase the reference count.
What happens if you use an unowned reference and the object it points to is deallocated?
✗ Incorrect
Unowned references assume the object always exists. If the object is deallocated, accessing an unowned reference causes a crash.
Explain in your own words why ARC is important for Swift developers.
Think about how ARC helps manage memory without you having to do it manually.
You got /4 concepts.
Describe what a strong reference cycle is and how you can avoid it in Swift.
Imagine two friends holding hands so tightly they can’t let go — that’s like a strong reference cycle.
You got /3 concepts.