iOS Interview Prep 4 — Event Handling & Responder Chain

Xiao.J
iOS Interview Prep Guide
4 min readMay 2, 2023

--

Event handling and the responder chain are very important concepts in iOS development, they are the fundamental and primary mechanism used for managing user interactions with the UI. Understanding how it works, you can not only ensure your app’s UI is responsive, but also be able to customize the way events are handled in your app.

Interview Questions

  1. Explain how hit testing works?
  2. What is the UIResponder object? Why is it useful, what does it enable you to do?
  3. How are events propagated and dispatched through the system via UIResponder?
  4. Explain the iOS Responder Chain?
  5. Why UIButton is not responsive?

Hit Testing

Hit testing is a process used in iOS to determine which view is currently under user’s finger or cursor. iOS uses hit-testing to determin which view is the frontmost view under the user’s finger.

The hit-testing process involves several steps:

  • OS generates events containing touch location
  • It then starts at the root view of the UI and checks if the touch point is within the bounds of a view. It is using an approach similar to DFS search algorithm.
  • It iterates all the subviews, checking if the touch point is within the bounds of any subview.
  • If a subview is a potential hit-test view, the…

--

--

Xiao.J
iOS Interview Prep Guide

Ex-Meta with 10+ years of experience in iOS Development 