Challenge - 5 Problems
Coordinator Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate1:30remaining
Why use the Coordinator pattern in iOS apps?
Which of the following best explains the main benefit of using the Coordinator pattern in an iOS app?
Attempts:
2 left
💡 Hint
Think about how navigation and screen transitions are handled in an app.
✗ Incorrect
The Coordinator pattern helps by moving navigation code out of view controllers, making them easier to maintain and test.
❓ ui_behavior
intermediate2:00remaining
Coordinator navigation flow
Given a Coordinator that starts with a Login screen and then shows a Home screen after successful login, what happens when the user logs in?
iOS Swift
class AppCoordinator: Coordinator { func start() { showLogin() } func showLogin() { let loginVC = LoginViewController() loginVC.onLoginSuccess = { [weak self] in self?.showHome() } navigationController.pushViewController(loginVC, animated: true) } func showHome() { let homeVC = HomeViewController() navigationController.pushViewController(homeVC, animated: true) } }
Attempts:
2 left
💡 Hint
Look at how navigationController is used to push view controllers.
✗ Incorrect
The code pushes Login screen first. When login succeeds, it pushes Home screen on top, so user sees Home next.
❓ lifecycle
advanced1:30remaining
Coordinator memory management
What is the main reason to use [weak self] in closures inside a Coordinator?
iOS Swift
loginVC.onLoginSuccess = { [weak self] in
self?.showHome()
}Attempts:
2 left
💡 Hint
Think about what happens if self holds a strong reference to the closure and vice versa.
✗ Incorrect
Using [weak self] avoids retain cycles between the Coordinator and closures, preventing memory leaks.
advanced
1:30remaining
Handling child coordinators
In a Coordinator pattern, why do we keep a strong reference to child coordinators?
Attempts:
2 left
💡 Hint
Think about what happens if a child coordinator is not strongly referenced.
✗ Incorrect
Without a strong reference, child coordinators get deallocated immediately, breaking navigation flow.
📝 Syntax
expert2:00remaining
Correct Coordinator protocol definition
Which option correctly defines a Coordinator protocol with a start() method and a navigationController property?
Attempts:
2 left
💡 Hint
The navigationController should be readable but not necessarily writable. start() returns nothing.
✗ Incorrect
Option D correctly declares a read-only navigationController and a start method with no return value.