Browse Questions
- These determine how ARC (Automatic Reference Counting) manages object lifetimes.
- TSCellSeal(key:) uses the bytes you supply directly as the symmetric key, while TSCellSeal(passphrase:) runs a human-typed string through a deliberately slow key derivation function first.
- A UIViewController goes through a predictable sequence of method calls as its view is created, displayed, and removed.
- Breakpoints pause execution so you can inspect state.
Answer:
A UIViewController goes through a predictable sequence of method calls as its view is created, displayed, and removed.
init → loadView → viewDidLoad → viewWillAppear → viewDidAppear
↓
viewWillDisappear → viewDidDisappear → deinit
Key methods and their purpose:
class MyViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Called once — set up UI, configure views, add subviews
setupUI()
bindViewModel()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
// Called every time view is about to appear — refresh data, show nav bar
navigationController?.setNavigationBarHidden(false, animated: animated)
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
// View is visible — start animations, begin location updates
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
// About to leave — pause video, resign first responder
}
override func viewDidDisappear(_ animated: Bool) {
super.viewDidDisappear(animated)
// Gone — stop timers, save state
}
}