Browse Questions
- TaskGroup lets you run multiple async tasks in parallel and collect all their results.
- The three modes differ in where the authentication token lives and whether the output grows: Seal appends the token to the ciphertext, Token Protect returns the token separately so the ciphertext…
- setNeedsLayout schedules a layout pass for later, layoutIfNeeded forces any pending layout to happen immediately, and setNeedsDisplay schedules a redraw of the view's content.
- The responder chain is a sequence of UIResponder objects that can handle events (touches, key presses, actions).
Answer:
The responder chain is a sequence of UIResponder objects that can handle events (touches, key presses, actions). Events travel up the chain until something handles them.
UIView → parent UIView → UIViewController → UIWindow → UIApplication → AppDelegate
Code Example:
// Custom action sent up the responder chain
// No need to know which object handles it
UIApplication.shared.sendAction(#selector(handleLogout), to: nil, from: nil, for: nil)
// Any UIResponder in the chain can handle it
class RootViewController: UIViewController {
@objc func handleLogout() {
// Handles the action wherever it is in the chain
AuthManager.shared.logout()
}
}
// First responder — the view currently receiving input
textField.becomeFirstResponder() // show keyboard
textField.resignFirstResponder() // hide keyboard